mercredi 5 mai 2021

How to get ID of Rows in DataGrid by checking the CheckBox?

enter image description here

I have a DataGrid with Checkbox on each row. How can I get column ID of all rows with the Checkbox checked and after clicking the apply button fill the List with these IDs?

<DataGrid SelectionMode="Extended" x:Name="dataGridListOfServices"  IsReadOnly="True"  SelectedItem="{Binding SelectedEmployeeData}" AutoGenerateColumns="True" FontFamily="Comic Sans MS" FontSize="16" Grid.Row="14" Grid.ColumnSpan="4" Grid.Column="1">
            <DataGrid.Columns>
                <DataGridTemplateColumn Width="SizeToHeader" IsReadOnly="True" Header="Выборка">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox Checked="chkSelect_Checked" Name="chkSelect"></CheckBox>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTextColumn Header="ID" Binding="{Binding FruitType}" Width="*"></DataGridTextColumn>
                <DataGridTextColumn Header="Item" Binding="{Binding Item}" Width="*"></DataGridTextColumn>
                <DataGridTextColumn Header="Qty" Binding="{Binding Qty}" Width="*"></DataGridTextColumn>
              </DataGrid>
        <Button x:Name="buttonApply" Content="Apply" Grid.Row="16" Grid.Column="1" Click="buttonApply_Click"></Button>



Aucun commentaire:

Enregistrer un commentaire