Hi Guys,
Its my first post to the WPF forum. I am stuck with cellvaluepresenter for conditionally formatting a particular cell. Here is my use case.
1) I have bound my grid to my business objects which has a property lets say 'Flag' , PropA & PropB,
2) I have 2 columns ColA & ColB, they are bound to properties PropA & PropB, when the underlying property Flag is set to true, I need ColA cell to flash its background to Red and need to change the value of ColB to 'XXX'. (I am using a XamNumericEditor for both ColA & colB)
I can achieve the flashing via storyboard , but cannot figure out a way to change the value of a bound column when DataTrigger enter action is fired and in the exit action use the bound value again.
Any help is appreciated.
StoryBoard for ColA
<igDP:Field Name="PropA" Label="ColA">
<igDP:Field.Settings>
<igDP:FieldSettings LabelTextAlignment="Center" EditorType="{x:Type igEditors:XamNumericEditor}">
<igDP:FieldSettings.CellValuePresenterStyle>
<Style TargetType="{x:Type igDP:CellValuePresenter}" BasedOn="{StaticResource ColAStyle}">
<Style.Triggers>
<DataTrigger Binding="{Binding DataItem.Flag}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard x:Name="blinkBeginFlag">
<Storyboard x:Name="BlinkFlag" AutoReverse="True" RepeatBehavior="Forever" Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)">
<ColorAnimation To="Red" Duration="0:0:1" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<RemoveStoryboard BeginStoryboardName="blinkBeginFlag" />
</DataTrigger.ExitActions>
</DataTrigger>
</Style.Triggers>
</Style>
</igDP:FieldSettings.CellValuePresenterStyle>
<igDP:FieldSettings.EditorStyle>
<Style TargetType="{x:Type igEditors:XamNumericEditor}" BasedOn="{StaticResource {x:Type igEditors:XamNumericEditor}}">
<Setter Property="Mask" Value="{}{double:-10.3}" />
<Setter Property="HorizontalContentAlignment" Value="Left"/>
</igDP:FieldSettings.EditorStyle>
</igDP:FieldSettings>
</igDP:Field.Settings>
</igDP:Field>
Hello Rajib,
Thank you for your post. I have been looking into it and I can suggest you see the sample in the Samples Browser under xamDataGrid / DataValueChanged Event section, where there is a sample showing how to use the DataValueChanged event, which will help you get the original cell of the value.
In the same vein, how can I change the background of a cell (possibly using Style/Trigger) only when the original value differs from the edited one. The original value and edited are not fixed.
Hello Jogesh,
I have modified the sample I sent you before, so now when the underlying data is changed the converter changes the value in the second Cell. Basically I handled the DataValueChanged event of the XamDataGrid and define the Flag property in order to set its DataValueChangedNotificationsActive to true.
Hope this helps you.
Hi Stefan,
Thanks for taking the time to look into this issue. I tried incorporating your suggestions in my code. But I have run into a couple of issues.
The main issue is that my event Grid_CellChanged is not firing, I have it wired to my grid, when the underlying Flag changes value to True I can see that my ColA storyboard begins and ends properly, but the cell changed is not called hence the Convertor we wrote does not re-evaluate.
From what I understand CellChanged is fired when we are editing the particular cell in the xamdatagrid, but here my underlying datasource is chaning, shoudnt we use a DataTriger as in ColA?
Looking forward to hearing from you.
Thanks,
Jogesh.
I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.