I have a WPF ListBox with some user cards inside.
When one of those user cards is created (in the ideal case, when the current user receives it's friend list from the network), it makes a network request for a user's information.
When I scroll in the ListBox , wait a few seconds, and scroll back, the user cards have their default state.
Upon debugging, I noticed they are unloaded and recreated.
How can I stop the ListBox from virtualizing the items like this?
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>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…