我有一个与 DataGridCheckBoxColumn 绑定的数据网格,我想获取选中复选框的行。
我的代码是这样的
<sdk:DataGrid x:Name="McDataGrid" Width="580" Height="250"
Margin="10,10,0,0"
ColumnWidth="100" RowHeight="30"
GridLinesVisibility="Vertical"
SelectionMode="Single"
BorderThickness="5"
AutoGenerateColumns="False"
AreRowDetailsFrozen="True"
HorizontalGridLinesBrush="Black"
VerticalGridLinesBrush="Black"
RowStyle="{StaticResource MyCustomRow}"
RowBackground="LightGray" AlternatingRowBackground="LightGray"
>
<!--Background="LightGray" RowBackground="LightYellow"
AlternatingRowBackground="LightBlue"
BorderBrush="Gray" -->
<!-- Add DataGrid Columns -->
<sdk:DataGrid.Columns>
<sdk:DataGridTextColumn Header="SL" Width="40" Binding="{Binding ID}" FontSize="12" />
<!--<sdk:DataGridTextColumn Header="Road Name" Width="100" Binding="{Binding RoadName}" FontSize="12" />-->
<sdk:DataGridTemplateColumn Header="Road Name" Width="300">
<sdk:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock TextWrapping="Wrap" Text="{Binding RoadName}" MaxHeight="200" />
</DataTemplate>
</sdk:DataGridTemplateColumn.CellTemplate>
</sdk:DataGridTemplateColumn>
<sdk:DataGridTextColumn Header="Start KM" Width="70" Binding="{Binding StartKM}" FontSize="12" />
<sdk:DataGridTextColumn Header="End KM" Width="70" Binding="{Binding EndKM}" FontSize="12" />
<sdk:DataGridCheckBoxColumn Header="Select" Binding="{Binding Available}" />
</sdk:DataGrid.Columns>
</sdk:DataGrid>
public class IntersectionRoads
{
public int ID { get; set; }
public string RoadName { get; set; }
public string StartKM { get; set; }
public string EndKM { get; set; }
public bool Available { get; set; }
}
McDataGrid.ItemsSource = intersectingRoads;
我想获取选中复选框的所有行值如果我在这里也做错了请指导
期待回复提前谢谢:)