Skip to main content
Home Forums Silverlight Programming Report a Silverlight Bug ListBox.ItemsSource - Switching from large list to smaller hangs browser/silverlight.
3 replies. Latest Post by masum.ahammed on June 27, 2009.
(0)
UncleRedz
Member
8 points
7 Posts
03-12-2008 2:10 PM |
Hi,
This one is a bit tricky to explain and possibly to reproduce, but basicly, take a ListBox and add a data template to it, similar to this (I used Scott's Digg data template as a starting point),
<Grid HorizontalAlignment="Stretch"><Grid.ColumnDefinitions><ColumnDefinition Width="Auto"/><ColumnDefinition/><ColumnDefinition Width="Auto"/></Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical" Grid.Column="0" Width="40" Margin="5" Style="{StaticResource ShadedListItem}"><TextBlock Foreground="DarkSlateGray" Style="{StaticResource ListItemBigTitle}" Text="{Binding track}" VerticalAlignment="Center" HorizontalAlignment="Center"/><TextBlock Foreground="DarkSlateGray" Style="{StaticResource ListItemDescription}" Text="{Binding duration, Converter={StaticResource DurationConverter}}" VerticalAlignment="Center" HorizontalAlignment="Center"/></StackPanel>
Then display this ListBox (resizing to available space) in a SL2B1 app and arrange the browser, IE7, in such a way that more than 10 but less than 11 complete items are visible.
With this setup, using code, set the ListBox.ItemsSource to a list of 15-20 items. Notice that a scroll bar is visible, don't scroll down.
Then change the ListBox.ItemsSource to a different list that contains 10 items, in other words just enough items to be visible without scrolling.
Doing this switch from the larger list to the smaller one results in something that looks like a busy loop, the CPU is maxed out and the browser stops responding. This doesn't happen all the time though, it depends on how the layout is before switching, if the browser is resized just a little, so that more or less of the list box items are visible, then this doesn't happen, so it's only when the layout is just "right".
Here's a workaround which forces the ListBox control to update it's layout before assigning the smaller list, which seems to solve the problem,
myListBox.ItemsSource = myLargeList;...myListBox.ItemsSource = null;myListBox.UpdateLayout();myListBox.ItemsSource = mySmallList;
Where as doing like this will fail,
myListBox.ItemsSource = myLargeList;...myListBox.ItemsSource = mySmallList;
If source is needed or just my full XAML file, then let me know and I'll happily send it.
Cheers
Yi-Lun L...
All-Star
25052 points
2,747 Posts
03-14-2008 5:09 AM |
Hello, maybe I don't understand you very well. But I can't seem to repro this issue. If you can, please share a project. Thanks.
03-14-2008 1:53 PM |
I've sent you an email, but I could not attach anything to it using this forums email contact form.
I'll prepare a test application to make it easier to reproduce.
masum.ah...
4 Posts
06-27-2009 1:18 AM |
I have same problem. I developed a chat application. I used ListBox for chat window. It working fine when data size is thin. When Chat history gets increased then the chat window gets hang. Can any one have any idea.
--Masum