I have a two stacked listboxes with data(first ListBox contains <10 elements, second may have up to 5000 elements),the elements of first listbox must be at top:
<ScrollViewer >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Listbox IsScrollable="False"/>
<Listbox Grid.Row="1" IsScrollable="False"/>
</ScrollViewer >
How I can improve perfomance of scrolling?
I know that I’ve lost virtualizingPanel when I call ” ScrollViewer.SetVerticalScrollBarVisibility(sender as ListBox, ScrollBarVisibility.Disabled);”
But is there any way to enable it when I need two ListBoxes?
Why you don’t want to use just one ListBox and set different Templates for different Data Types? You will not need to do any additional work to improve performance of scrolling.
Check this MSDN article Data Templating Overview, you will find one of the latest samples uses DataTemplateSelector and SL doesn’t have this class, but you can find a lot of blog posts which trys to solve this problem in SL/WP: Implementing Windows Phone 7 DataTemplateSelector and CustomDataTemplateSelector. So if you will use this approach – you just need to be sure that you will bind to your collection and your collection will have a right order of elements: 10 elements from first ListBox, other elements from second ListBox.