Is the default listbox virtual?

I have a ListBox WPF with some custom maps inside.
When one of these user cards is created (ideally, when the current user receives a list of friends from the network), he makes a network request for user information.
When I browse the ListBox, wait a few seconds and scroll back, custom maps have a default state.
After debugging, I noticed that they were unloaded and recreated.

How can I stop a ListBox from virtualizing such items?


Code:

<ListBox x:Name="friend_list" Background="{x:Null}" BorderBrush="{x:Null}"> <ListBox.ItemTemplate> <DataTemplate DataType="data:User"> <stuff:UserCard UserID="{Binding Path=UserID}" HorizontalAlignment="Stretch" Margin="0,0,0,0" /> </DataTemplate> </ListBox.ItemTemplate> </ListBox> 
+4
source share
1 answer

Set VirtualizingStackPanel.IsVirtualizing to false in the ListBox or set the normal StackPanel to ListBox.ItemsPanel .

+7
source

Source: https://habr.com/ru/post/1445263/


All Articles