我使用我在互联网上找到的这段代码实现了一个带有复选框的 DataGrid。
<my:DataGrid.RowHeaderTemplate>
<DataTemplate>
<Grid>
<CheckBox IsChecked="{Binding Path=IsSelected, Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type my:DataGridRow}}}" />
</Grid>
</DataTemplate>
</my:DataGrid.RowHeaderTemplate>
但是,我怎样才能获得选定的行?我正在使用 WPF MVVM。