I have a WPF ListView control, ItemsSource is set to an ICollectionView created this way:
var collectionView =
System.Windows.Data.CollectionViewSource.Ge
Cheeso's solution DOES work for me. Prevent the null exception by just setting a timer.tick to do this, so you have left your original routine.
var uiel = (UIElement)this.lv1.ItemContainerGenerator
.ContainerFromItem(lv1.Items[ix]);
if (uiel != null) uiel.Focus();
Problem solved when calling timer after a RemoveAt/Insert, and also at Window.Loaded to set focus and select to first item.
Wanted to give back this first post for the much inspiration and solutions I got at SE. Happy coding!