dimanche 4 décembre 2022

C# WPF DataGrid Save changes - Binding Classes

currently I'm trying to get new values from the Datagrid in WPF, in this case a CheckBox and to export it or whatever. Unfortunately, nothing works in my case.

I have a DataGrid with a DataGridTemplateColumn, at the end there's a CheckBox. The value is binded to a bool-variable.

Now I want the user to change the value (e.g. uncheck the CheckBox) and save this value.

XAML:

<DataGridTemplateColumn Header="Export?" Width="100">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate >
                            <CheckBox Margin="20, 0" IsChecked="{Binding toExport}"/>

When I export all Items within the DataGrid, only the old values from the initial item are exported. I tried to work with CellEditingTemplate, but there no values are shown. What am I doing wrong?

<DataGridTemplateColumn Header="Test">
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <CheckBox Margin="20, 0" IsChecked="{Binding toExport}"/>

I really tried to find a solution on the internet, but I cannot find any clues unfortunately. Is there somewhere an information which I might have overlooked?

Thank you very much :)




Aucun commentaire:

Enregistrer un commentaire