Nikhil Agrawal Nikhil Agrawal - 29 days ago 12
C# Question

XamTextEditor Text Value Trigger applies once but Fails later

I have a XamDataGrid and used XamTextEditor like this

<dp:Field Name="Status" Label="Status">
<dp:Field.Settings>
<dp:FieldSettings AllowEdit="False"
EditorStyle="{StaticResource StatusStyle}" CellWidth="100" />
</dp:Field.Settings>
</dp:Field>


and style like this

<Style x:Key="StatusStyle" TargetType="{x:Type igWpf:XamTextEditor}">
<Setter Property="FontSize" Value="11" />
<Setter Property="FontWeight" Value="Bold" />
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,
AncestorType=dataPresenter:CellValuePresenter},
Path=Record.DataItem.Status}" Value="New">
<Setter Property="Background" Value="{StaticResource DkRed}" />
<Setter Property="Foreground" Value="AntiqueWhite" />
<Setter Property="Text" Value="Awaiting Pickup" />
</DataTrigger>
</Style.Triggers>
</Style>


The style applies when loaded. It shows "Awaiting Pickup" as Text. But if we scroll, and record is scrolled (goes and comes) back, it shows actual value of Status field/property i.e. New.

Interesting thing is that Foreground and Background remains as they are in trigger.

Why this behaviour? Any thing missing which I have to set?

Answer

After not finding any answers here, I asked this from Infragistics Support and they asked me to use ValueToDisplayTextConverter property. Using its converter I have moved the text, which is displayed, outside of the trigger.

On asked why on scroll only text changes and not background and foreground.

The XamDataGrid's performance optimization requires Cells to be loaded when they are needed to be visualized on the screen. Furthermore when they are scrolled out of view they are not always cleaned (cashing), the element is kept and used again.

You can find out more in these articles: http://help.infragistics.com/doc/WPF/2016.1/CLR4.0/?page=xamData_Performance_Optimizations_Overview.html

http://help.infragistics.com/Help/Doc/WPF/2016.1/CLR4.0/html/xamData_Cells_CellValuePresenters_and_Cell_Virtualization.html