Alexandre
Alexandre

Reputation: 13308

Always have one selected DataGrid row

I'm working with WPF dataGrind now and faced with an ussie. I need that dataGrid always has one selected row. Always and only one.

Is it possible?

Upvotes: 0

Views: 1173

Answers (1)

blindmeis
blindmeis

Reputation: 22445

try this:

<DataGrid SelectionMode="Single" SelectionUnit="FullRow" PreviewMouseDown="PreviewMouseDown"/>

edit:

    private void PreviewMouseDown(object sender, MouseButtonEventArgs e)
    {
        if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
            e.Handled = true;
    }

Upvotes: 2

Related Questions