Arrow keys don't work after programmatically setting ListView.SelectedItem

前端 未结 9 1747
感情败类
感情败类 2020-12-16 02:34

I have a WPF ListView control, ItemsSource is set to an ICollectionView created this way:

var collectionView = 
  System.Windows.Data.CollectionViewSource.Ge         


        
9条回答
  •  时光取名叫无心
    2020-12-16 03:14

    It's possible to focus an item with BeginInvoke after finding it by specifying priority:

    Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(() =>
    {
        var lbi = AssociatedObject.ItemContainerGenerator.ContainerFromIndex(existing) as ListBoxItem;
        lbi.Focus();
    }));
    

提交回复
热议问题