<Grid.Resources> <local:PersonCollection x:Key="people"> <local:Person ID="1" FirstName="Joe" LastName="Blow" /> <local:Person ID="2" FirstName="Sam" LastName="Blam" /> <local:Person ID="3" FirstName="Jack" LastName="Black" /> <local:Person ID="4" FirstName="Hugo" LastName="Blue" /> </local:PersonCollection> </Grid.Resources> <DataGrid x:Name="dataGrid" ItemsSource="{Binding Source={StaticResource people}}" IsSynchronizedWithCurrentItem="True" > <DataGrid.Columns> <DataGridCheckBoxColumn Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=DataGridRow}}" /> </DataGrid.Columns> </DataGrid>
Monday, March 15, 2010
How to select a row in the WPF DataGrid using a CheckBox
This is fairly simple to achieve in the WPF DataGrid, all you need to do is add a DataGridCheckBoxColumn to the Columns collection of the data grid, and then bind it to the IsSelected property of the DataGridRow that is hosting it.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment