1
Vote

usercontrol loaded event doesn't fire, missing loaded event

description

When there are many items in listbox, the listbox item template loaded event doesn't fire.

I have made a template for the ItemTemplate property of ListBox:
        <ListBox x:Name="lb" Grid.Row="1">
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Vertical"/>
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <local:ListBoxItemTemplate />
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
I have handled the loaded event of local:ListBoxItemTemplate :
        void ListBoxItemTemplate_Loaded(object sender, RoutedEventArgs e)
        {
            System.Diagnostics.Debug.WriteLine(i++);
        }
But, on my side, when the items number is over 5000, there are some loaded event doesn't fire.
When I increase the number to 100000, there is no loaded event any more.
Is this a bug? Or I missed any thing?

I have attached a completely sample here, you can change the amount in the ListBoxDataViewModel.cs file.

file attachments

comments