Reputation: 333
In windows phone I have a LongListMultiSelector control that has multi selection made by the user and the selection is saved in a file.
Then If the user tries to load his selection from the file loads fine and selected items are selected again using IsSelected property.
My question is that Why only visible items are checked while other selected items that are outside the view are unchecked ,How can I make them checked also?
Upvotes: 1
Views: 387
Reputation: 65
LonglistMultiSelector doesn't load all of the items at startup, loads items that are needed instead (see ItemRealized and ItemUnrealized events). Since some of the items that you want to select are not assigned to UI, you can't select them. You can workaround this by scrolling to that item.
I've used the following code to select all items in a LongListMultiSelector.
foreach (ViewModels.ItemViewModel item in longListMultiSelector.ItemsSource)
{
LongListMultiSelectorItem container = longListMultiSelector.ContainerFromItem(item) as LongListMultiSelectorItem;
if (container == null)
{
// item has't been assigned to UI
longListMultiSelector.ScrollTo(item);
container = longListMultiSelector.ContainerFromItem(item) as LongListMultiSelectorItem;
}
container.IsSelected = true;
}
Upvotes: 1