How to set selected item of a DataGrid programmatically in WPF with MVVM application?

后端 未结 5 1491
滥情空心
滥情空心 2021-01-02 11:17

I have bound the DataTable to the DataGrid control. How can I set the selected item programmatically ?

Exam

5条回答
  •  一个人的身影
    2021-01-02 11:43

    You can always use SelectedItem property and bind it against row, as such:

    SelectedItem="{Binding ActiveRow}"
    

    and in ViewModel do:

    ActiveRow = secondRow;
    

提交回复
热议问题