mercredi 27 novembre 2019

CheckBox in DataGrid

Hi I create this code for understand why if put a checkbox out to datagrid all work but if insert a checkbox into datagrid don't work.

This run correct:

      <CheckBox x:Name="checkBox" Content="Test" Margin="0" Command="{Binding SelectCommand}" CommandParameter="{Binding IsChecked, RelativeSource={RelativeSource Self}}"/>

But this not:

<DataGrid x:Name="dataGrid" ItemsSource="{Binding XMLValue}" >
        <DataGrid.Columns>
            <DataGridTemplateColumn>
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <CheckBox x:Name="TestCheckBox" Command="{Binding Path=SelectCommand, RelativeSource={RelativeSource FindAncestor, AncestorType=DataGrid}}"  IsChecked="{Binding Path=Selected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
        </DataGrid.Columns>
    </DataGrid>

SelectCommand is only a MessageBox.Show

(thank you and sorry for my english)




Aucun commentaire:

Enregistrer un commentaire