这种简单的WPF的DataGrid中的DataGrid CURRENTITEM =的SelectedItem与制表键
<DataGrid AutoGenerateColumns="False" Height="300" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" Name="dgOriginal" Margin="4,12,0,0"
CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False" IsSynchronizedWithCurrentItem="True"
CanUserSortColumns="False" SelectionMode="Single" SelectionUnit="FullRow">
<DataGrid.Columns>
<DataGridCheckBoxColumn x:Name="col2Checked"/>
<DataGridTextColumn x:Name="col2Name"/>
<DataGridTextColumn x:Name="col2Vorname"/>
</DataGrid.Columns>
这说明没有问题绑定列表,表现在一种奇怪的方式获得焦点时回折返后: 首先,用户选择一行,使数据网格以选定的方式显示该行(SelectedItem和CurrentItem包含所选对象)。然后把重点放在另一个控制上。在这种状态下 - 选择仍然显示 - SelectedItem仍然存在,而CurrentItem为空!然后焦点通过使用TAB按钮回来。这使得CurrentItem成为SelectedItem未被更改时显示的第一个对象。所以CurrentItem不会与SelectetItem一起在DataGrid中看到的状态中。我认为对自己有什么好处...
我的疑问是:如何建议DataGrid具有相同的CurrentItem之前被选中的焦点丢失?以及如何同步CurrentItem和SelectedItem?
我希望能有一个简单的解决方案!你会帮助我很多。在此先感谢...
谢谢您的帮助!但是恐怕你的建议不能解决问题:在使用Tab按钮重新登录后,我仍然在第一列看到这个丑陋的小框标记CurrentItem行。并且,如果用户使用键盘在DataGrid中导航,则所选行将更改为CurrentItem行,但似乎SelectedItem始终跟随CurrentItem ... – navigato 2012-02-15 23:27:40