Restore state of listview connected with CollectionViewSource
Hi it's 10 days that I'm stuck on saving and restoring state of ListView connected to collection ViewSource
there's nothing special... the problem is that when I try to restore state save scrollview(extracting from ListView) position (VerticalOffset), then restoring, the position of scroll is wrong, so for eg. items in the middle of the listview are wrong.
In few words all seem works, I mean saving and restoring, but actually the scroll position is completely wrong, when I try to restore scrollposition near middle of the list, if the position to restore is near bottom or top it works fine.
So, I mean, if I scrolled near item in the middle, then suspending and resuming the position is not right but is some items down...
the listview is groupped with albums (group ) and songs (item), nothing special, here's a piece of code
restore
/// <summary>
/// Invoked when this page is about to be displayed in a Frame.
/// </summary>
/// <param name="e">Event data that describes how this page was reached.
/// This parameter is typically used to configure the page.</param>
protected override void OnNavigatedTo(NavigationEventArgs e)
//RESTORE
if (!string.IsNullOrWhiteSpace(_pageKey)) return; //vuol dire che lo stato è caricato e non necessita altro
this._pageKey = "PageSongView";
var frameState = SuspensionManager.SessionStateForFrame(this.Frame);
if (frameState.ContainsKey(_pageKey))
var pageState = frameState[_pageKey] as Dictionary<String, Object>;
if (pageState.ContainsKey("AlbumListIn.VerticalOffset"))
var v_offset = (double?)pageState["AlbumListIn.VerticalOffset"];
AlbumListIn.Loaded += (snd, arg) =>
var scroll_viewer = VisualTreeHelperEx.ScanVisualTree<ScrollViewer>(AlbumListIn).First();
scroll_viewer.Loaded += (snd2, arg2) =>
scroll_viewer.ChangeView(null, v_offset, null, false);
save
protected override void OnNavigatedFrom(NavigationEventArgs e)
//SAVE
var frameState = SuspensionManager.SessionStateForFrame(this.Frame);
var pageState = new Dictionary<String, Object>();
_saveState(pageState);
frameState[_pageKey] = pageState;
private void _saveState(Dictionary<string, object> pageState)
var scroll_viewer = VisualTreeHelperEx.ScanVisualTree<ScrollViewer>(AlbumListIn).First();
pageState["AlbumListIn.VerticalOffset"] = (double?)scroll_viewer.VerticalOffset;
var k = 0;
in the xaml
<ListView x:Name="AlbumListIn"
ItemsSource="{Binding Source={StaticResource AlbumCollection}}"
XamlHlp:XamlHelper.SetItemsCommand="{Binding Path=VM.SongItemControl.SelectedSongItemsCommand, Source={StaticResource SongService}}"
SelectionMode="{Binding Path=VM.SongItemControl.IsMultipleSelection, Source={StaticResource SongService},Converter={StaticResource BoolSelMode}}"
Style="{StaticResource AlbumSongZoomInStyle}"
>
<ListView.GroupStyle>
<GroupStyle HeaderTemplate="{StaticResource AlbumListGroupHeaderDT }">
</GroupStyle>
</ListView.GroupStyle>
</ListView>
please help me I'm really stuck and I don't find any solution...
>In few words all seem works, I mean saving and restoring, but actually the scroll position is completely wrong, when I try to restore scrollposition near middle of the list, if the position to restore is near bottom or top it works fine.
I think this may be due to cached UI layout, this need to measure again manually:
https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.uielement.measure.aspx?f=255&MSPPError=-2147217396
https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.uielement.arrange.aspx
If the above methods are not working, share a demo.
Best Regards,
Please remember to mark the replies as answers if they help
Similar Messages
-
When I plug my "restored" 6 Plus, the connection with my iMac
When I plug in my "restored" 6 Plus, the connection with my iMac & iTunes is fast & smooth. BUT, as I add more Playlists to the phone, the color wheel starts & each steps slows to 10-30 seconds. After I restore, it's quick again. Thoughts? I am running Yosemite, the new iTunes and the latest iPhone 6 iOS. This never happened with any phones up to my 5S, but has happened consistently with my 6 and 6 Plus.
I aporeciate the reply, but do recommend this if I only click & certain playlists? I'm an album weirdo. The more albums I manually clicked & dragged, the slower each step took (clicking the phone, hitting "add", hitting "playlists", hitting the actual playlist, the dragging it to the phone. The more gigs of music on the phone, the more the color wheel spins with each step....but like I mentioned, after I've restored, it's very fast
-
When I plug in my "restored" 6 Plus, the connection with my iMac
When I plug in my "restored" 6 Plus, the connection with my iMac & iTunes is fast & smooth. BUT, as I add more Playlists to the phone, the color wheel starts & each steps slows to 10-30 seconds. After I restore, it's quick again. Thoughts? I am running Yosemite, the new iTunes and the latest iPhone 6 iOS. This never happened with any phones up to my 5S, but has happened consistently with my 6 and 6 Plus. I click and drag Playlists.
I aporeciate the reply, but do recommend this if I only click & certain playlists? I'm an album weirdo. The more albums I manually clicked & dragged, the slower each step took (clicking the phone, hitting "add", hitting "playlists", hitting the actual playlist, the dragging it to the phone. The more gigs of music on the phone, the more the color wheel spins with each step....but like I mentioned, after I've restored, it's very fast
-
After connect with Itunes, choosing restore, then all the photos lost.
I bought a New Iphone5 and using it to took some photos.
then I connect with Itunes which provide me two options, I choosed the retore. after restore, all the photo lost. what can i do.It can not do that all by itself.
When you plugged it in, iTunes said 'Oh goody! You got a new phone! Would you like to make it just like your old phone?'...
You explicitly said 'Yes'.
You can't undo that.
No backup of the current state of the new phone was made. It was wiped and the last backup of your old phone was restored to it.
Anything you had on the new phone is gone. -
How to restore my ipad?My ipad say on screen CONNECT TO ITUNE.How can i do when i connect with computer.It is need itune new version.Can you sent me.I will be waiting your answer.Please help me sir.
Check for Updates.
http://i1224.photobucket.com/albums/ee374/Diavonex/Album%208/78d42b19fa42e8d83b5 5a65e1333373f_zpsf58bbe10.jpg -
Hi,
For no apparent reason my phone stopped working...so I did a reset and got the message 'Restore Needed'. I connected to iTunes and got this message: 'iTunes could not connect to the iPhone because it is locked with a passcode. You must enter your passcode on your iPhone before it can be used with iTunes'.
The problem is, I can't enter my passcode because I'm not given that option on the iPhone. All I seem to be able to do is make an emergency call.
It's been working fine otherwise. Any suggestions?
This is the SECOND replacement iPhone I've had this week and I'm getting a bit fed up.
Thanks in advance for any help,Are you referring to the 4 digit passcode needed to enter the phone and use it's features?
If so reboot your iPhone and enter the passcode to get it operational. Launch Image Capture on the Mac and connect the iPhone. Now you should be able to download the video files to wherever you want on your hard drive.
OT -
Hey guys. My IPhone 3GS is unlocked and i went to update the software and it said that an unknown error has occurred and said it needed to be restored to connect with Itunes. When i got to restore it, it gets about 3/4 of the way done, says an unknown error has occured(1015). I have no clue what to do and all and any help would be amazing.
See Here
https://discussions.apple.com/message/15290457#15290457
From the More Like This on the right... -
I did a full system restore to my phone along with the new 7.0 update. Now I went to restore my phone setting back through Itunes and it goes through all the steps but when it is completed it wont get past the "Connect to Itunes" screen
So what happens when you connect to iTunes?
-
I have connected my ipad to my computer and logged into iTunes website. On my iPad to restore my my data Ipad I have chosen language, country then it asks you to connect with cable and log into iTunes, I have done that, but cannot find this other information I need to restore from the website. Can you help me please? the 2 replies, I thank you, but this has not helped with my problem.
Your post is somewhat confusing. To restore your iPad you use the iTunes application on your computer and connect your iPad. Select your iPad in the left column of iTunes on your computer and select General in the right column. You should find the restore choice there.
-
after lion 10.7.3 update messed my mac had to restore from time machine now Outlook won't connect with microsoft exchange, any idea?
I've had a similar problem. On my first boot up after installing 10.7.4, Firefox would not open. Crashed every time. Safari was not affected. I have no idea if it was related to the flash plugin, but I did install a the latest version of that a couple of weeks ago.
Here's what fixed it: a second boot up. -
updated to ios6 on my ipod touch 4g when i try to turn it on it doesn't, it just comes up with the itunes symbol and the usb, so i plugged into laptop opened itunes and it says to restore back to ios5 i pressed restore and it cant connect to server? help?
Maunally restore it. In order to do this:
-Download the iOS 5.1.1 firmware from here http://www.redmondpie.com/download-5.1.1-ios-for-iphone-4s-4-3gs-ipad-ipod-touch -direct-official-links/
1. After downloading the firmware from the given link, open iTunes and click on your device.
2. Now press SHIFT on your keyboard and while pressing it click on "Restore".
3. A dialog box will appear.
4. Select the firmware you downloaded and click ok.
5. Done!!! Your iPhone will now be restored to 5.1.1 and if you had backed up your iPod before, then you can put all its settings afterwards. -
My iphone4 has been stuck on the connect to itunes logo for a few hours. I connected it to itunes and it says that the iphone is on recovery mode and that I need to restore it to use it with itunes. I'm afraid that if I restore it I will loose everything help please!!
AT this point whatever data you have on yoru phone is already gone since it is in recovery mode.
However you can restore from your backup, when your phone reboots from recovery.
YOu do have a backup right? -
3rd gen iPod won't connect with firewire...how can I restore it?
As many others have had this problem, my iPod only charges when connected with firewire. When I connect with USB, it says "Use the iPod Software Updater application to restore the iPod to factory settings"
When I try the iPod Software Updater, it says I need to connect via Firewire.
Question 1: Any ideas on how to restore the iPod?
Question 2: Any ideas on how to get the firewire functional again?
Many thanks in advanceAnswer to Question 1: - I connected the iPod with the USB, went to Disk Utility and erased the iPod. Now the iPod works with USB.
Question 2 is still unanswered. Ideas? -
I cannot create a new Business Catalyst site with Dreamweaver CC 2014 (Mac). The error message states that Dreamweaver cannot connect with server, try again later. In addition, I am also unable to load remotely a previously created Business Catalyst site as it says there is something wrong with my username or password. However when I put my password in and press test connection, it says it has connected successfully. What is going wrong and how can I fix this problem?
ThanksHi Ozy08,
Can you try the solutions mentioned in Re: Can't Login to Business Catalyst within Dreamweaver CS6?
If you still have problems, and you have a purchased version of DW CC, send me your Adobe ID, location, and contact details over a private message. Click my picture and use the message option.
Thanks,
Preran -
iphone 4 - yesterday it popped up to update to IOS7.... now it is froze on the screen as a picture (one end of connection with arrow up to itunes written out to itunes icon"..... ive tried restoring and it says "the iphone "iphone" could not be restored. Device not found".... although i do have it connected to my puter and have itunes activated.
i wished some one have warned me about this mess...
JudyiOS: Unable to update or restore
Maybe you are looking for
-
After Drive Replacement, iTunes Points To Wrong Folder Even After Adjusting Settings
I moved my music to a new hard drive. I then adjusted settings within iTunes to "point" to the folder on the new drive. The folder name is identical as are all the files within it. I did this a few months back and had no issues once iTunes "located"
-
Assigning data from one Table type to another structure
Hi every one, I have a table type X sent from one function module to another Proxy generated method which has the parameter defined as a structure. I have declared a variable Y as a LINE TYPE OF X. Then I have this statement which fills up the data.
-
[Mac] Illustrator freezes while loading plugins
Hi all, We have Adobe Creative Suite CS5 Design Premium installed on an iMac running OS X 10.9.5. No internet connection available (machine in a locked down environment) The issue: Illustrator and InDesign freezes for around 60 secs when GUI is loade
-
Create pdf without 3rd control etc
i want to create pdf in silverlight,write code to achieve this. i don't wnat a third party control
-
Installing Elements 10 on a Mac Mini
I cannot figure out how to intall Elements. I have already installed a new copy of Lightroom 4 that i just bought but the install of Elements is completely different and I don't know where to begin except with disk #3. Can you help me?