【发布时间】:2018-07-24 00:24:51
【问题描述】:
我在 ListView1 中使用了一个 SelectionChanged 事件,它更改了一个字符串:“dr.CustomBackgroundColor”。该字符串用于查找索引并更改目标 ListView 中的选择:“SetColorListView”。哪个按预期工作!
但“SetColorListView”中的选择不会“跳转”到视图中。 IE。它被选中了,但我必须滚动才能找到它...
有没有一种简单的方法可以让 SelectedItem 自动进入视图?
<ListView x:Name="SetColorListView" Focusable="False"
ItemsSource="{Binding SystemColorObservableCollection, UpdateSourceTrigger=PropertyChanged}"
SelectedValuePath="HexValue"
SelectedValue="{Binding objGantChartClass.CustomBackgroundColor, Mode=TwoWay}"
SelectedIndex="{Binding SystemColorObservableCollectionSelectedIndex, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsSynchronizedWithCurrentItem="True">
SystemColorObservableCollectionSelectedIndex = SystemColorObservableCollection.IndexOf(SystemColorObservableCollection.Where(c => c.HexValue == dr.CustomBackgroundColor).FirstOrDefault());
【问题讨论】: