Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I found the reason behind this, so the solution. I used a DockPanel to layout my UI. I put my status bar at the bottom, the ListBox on the Left and other items are on middle and top. There is a TextBlock in my StatusBar which has width and Height set to Auto. So, when I changed text of my StatusBar TextBlock it's width and height gets recalculated and It's parent's recalculates it's layout. Hence the ListBox gets invoked to Measures and Arrange. Even though it's size does not gets changed it resets it's scroll position to top. It happens only if I use ScrollViewer.CanContentScroll="True" at the ListBox. By default it is True. So, even though I did not set this value It was resetting the scroll position. If I disable it by using ScrollViewer.CanContentScroll="False" then it works fine.</p> <pre><code>&lt;ListBox Name="Tree" DockPanel.Dock="Top" ItemsSource="{Binding DataSource.OrderedLibraryItems}" Background="{StaticResource LibraryBackground}" Width="220" HorizontalAlignment="Left" BorderThickness="0" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Standard" ScrollViewer.IsDeferredScrollingEnabled="True" ScrollViewer.CanContentScroll="False" ItemTemplate="{StaticResource ListLibraryItemTemplate}" SelectionMode="Single" MouseDoubleClick="HandleMouseDoubleClick" /&gt; </code></pre> <p>But setting ScrollViewer.CanContentScroll="False" disables virtualization and I want to use virtualization to my ListBox so I set fixed Height and Width to the TextBlock. So, the DockPanel does not re-arrange it's children if I change the status message. </p> <p>May be it's a bug at ScrollViewer. It should not change the scroll position if the size has not changed.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload