WPF Datagrid set selected row

后端 未结 8 1368
无人共我
无人共我 2020-11-27 05:08

How do I use the Datagrid.SelectedItem to select a row programmatically?

Do I first have to create a IEnumerable of DataGridRow

8条回答
  •  鱼传尺愫
    2020-11-27 05:35

    I've searched solution to similar problem and maybe my way will help You and anybody who face with it.

    I used SelectedValuePath="id" in XAML DataGrid definition, and programaticaly only thing I have to do is set DataGrid.SelectedValue to desired value.

    I know this solution has pros and cons, but in specific case is fast and easy.

    Best regards

    Marcin

提交回复
热议问题