Hello,
I have a DataGrid with a dataSource binding to a collection.
A trigger with a CellUpdated event.
The method that is called as soon as you make a change to the cell is in my ViewModel.
I want to change the color of the cell and row concerned as soon as there is change
.xaml :
.cs :
public void XamDataGridCellUpdated(object sender, CellUpdatedEventArgs e) {
var xamDataGrid = sender as XamDataGrid;
}
How could I do ?
Thanks for any thoughts.
Sorry, I forgot .xaml
<igDP:XamDataGrid Name="XamDataGridTableData" DataSource="{Binding TableData}"> <i:Interaction.Triggers> <i:EventTrigger EventName="CellUpdated" x:Name="interactivityFix" SourceName="XamDataGridTableData"> <ei:CallMethodAction x:Name="interactionsFix" MethodName="XamDataGridCellUpdated" TargetObject="{Binding}"/> </i:EventTrigger> </i:Interaction.Triggers> </igDP:XamDataGrid>
public void XamDataGridCellUpdated(object sender, CellUpdatedEventArgs e){
Hello Lepage,
You can use the approach from the following forum thread in order to change the cell background:
https://ko.infragistics.com/community/forums/t/14111.aspx
1. Use the Tag property on the Cell, so in the CellUpdated event set Cell.Tag to a Boolean true .2. Bind the Tag of the CellValuePresenter to a multibinding that binds to the CellValuePresenter's Field and Record to obtain the Cell and then set the CellValuePresenter style trigger to bind to the Tag.Tag(i.e. Cell.Tag) .
<Style TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="Tag"> <Setter.Value> <MultiBinding Converter="{StaticResource fieldRecordToCell}"> <Binding RelativeSource="{RelativeSource Self}" Path="Field" /> <Binding RelativeSource="{RelativeSource Self}" Path="Record" /> </MultiBinding> </Setter.Value> </Setter> <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Tag.Tag, Converter={StaticResource keepChangedCellStyle}}" Value="True" > <Setter Property="Background" Value="Yellow"/> </DataTrigger> </Style.Triggers></Style>
I have attached a simple sample application, where you can test this approach.
Let me know if you have any questions.
Sincerely,ZhivkoAssociate Software Developer
Zhivko,
Thanks for your help, that's exactly what I wanted ^^