Nikhil Agrawal Nikhil Agrawal - 1 year ago 171
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:FieldSettings AllowEdit="False"
EditorStyle="{StaticResource StatusStyle}" CellWidth="100" />

and style like this

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

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 Source

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:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download