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

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?