我现在正在使用WPF dataGrid并面临一个问题。我需要dataGrid始终有一个选定的行。永远只有一个。
有可能吗?
答案 0 :(得分:2)
试试这个:
<DataGrid SelectionMode="Single" SelectionUnit="FullRow" PreviewMouseDown="PreviewMouseDown"/>
编辑:
private void PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
e.Handled = true;
}