When I change the value of any cell in a row, I want to dynamically change other cells in the same row. For example, in the following grid, when I change 1 to 3 in the second row, the value of 5 must change to 3. (The edit button only saves changes into the database.)
Here's the xaml code of my DataGrid
. I have tried using SelectedCellsChanged
and SelectionChanged
events but I wasn't successful.
<DataGrid x:Name="MyDataGrid" x:Uid="MyDataGrid" AutoGenerateColumns="False"
Height="226" HorizontalAlignment="Left" Margin="106,111,0,0"
VerticalAlignment="Top" Width="684" ColumnWidth="*"
AlternationCount="2" SelectionMode="Single"
SelectedCellsChanged="MyDataGrid_SelectedCellsChanged"
SelectionChanged="MyDataGrid_SelectionChanged" >
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Path=ProductName}" Header="Ürün Adı" />
<DataGridTextColumn Binding="{Binding Path=StoreName}" Header="Şube Adı" />
<DataGridTextColumn Binding="{Binding Path=Day1}" Header="Pazartesi" />
<DataGridTextColumn Binding="{Binding Path=Day2}" Header="Salı" />
<DataGridTextColumn Binding="{Binding Path=Day3}" Header="Çarşamba" />
<DataGridTextColumn Binding="{Binding Path=Day4}" Header="Perşembe" />
<DataGridTextColumn Binding="{Binding Path=Day5}" Header="Cuma" />
<DataGridTextColumn Binding="{Binding Path=Day6}" Header="Cumartesi" />
<DataGridTextColumn Binding="{Binding Path=Day7}" Header="Pazar" />
<DataGridTemplateColumn Header="Edit Row">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Content="Edit" Click="EditButton_Click" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>