private void ToggleCategorySelection(Category category) { MultiselectItem container = categoriesListBox.ItemContainerGenerator.ContainerFromItem(category) as MultiselectItem; if (null != container) { container.IsSelected = !container.IsSelected; } }
private void selectItemOnPageLoaded(Category category) { MultiselectItem container = categoriesListBox.ItemContainerGenerator.ContainerFromItem(category) as MultiselectItem; if (null != container) { container.IsSelected = !container.IsSelected; } else { //on long list the container could be null since the list is not fully rendered on the screen, so we can't select items at the end of the list categoriesListBox.SelectedItems.Add(category); } }