Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
155
CellValuePresenter foreground style behavior oddly (maybe since update to v13.2 from v12.2)
posted

We have an XamDataGrid where based on a DataTrigger, we would like the foreground color to change.  Recently this style has started acting up in that I could repeatedly rebind the data to the XamDataGrid and sometimes the style (based on DataTrigger) would be respected and others it wouldn't.  In summary, the same row of data with the same condition that would trigger (via DataTrigger) the style would sometimes properly show the changed foreground, and others would revert to Black.


The style is defined as (Consider that InactiveInmate represents a light grey color):

<Style TargetType="{x:Type igDP:CellValuePresenter}" BasedOn="{StaticResource {x:Type igDP:CellValuePresenter}}">
<Style.Triggers>
<DataTrigger Binding="{Binding DataItem.CustodyStatus}" Value="I">
<Setter Property="FontStyle" Value="Italic"/>
<Setter Property="Foreground" Value="{StaticResource InactiveInmate}"/>
<Setter Property="ForegroundStyle">
<Setter.Value>
<Style>
<Setter Property="TextBlock.Foreground" Value="{StaticResource InactiveInmate}"/>
</Style>
</Setter.Value>
</Setter>
</DataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding DataItem.CustodyStatus}" Value="I"/>
<Condition Binding="{Binding Path=IsMouseOver, RelativeSource={RelativeSource AncestorType={x:Type igDP:DataRecordCellArea}}}" Value="True"/>
</MultiDataTrigger.Conditions>
<Setter Property="ForegroundStyle">
<Setter.Value>
<Style>
<Setter Property="TextBlock.Foreground" Value="{StaticResource InactiveInmate}"/>
</Style>
</Setter.Value>
</Setter>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding DataItem.CustodyStatus}" Value="I"/>
<Condition Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource AncestorType={x:Type igDP:DataRecordCellArea}}}" Value="True"/>
</MultiDataTrigger.Conditions>
<Setter Property="ForegroundStyle">
<Setter.Value>
<Style>
<Setter Property="TextBlock.Foreground" Value="{StaticResource InactiveInmate}"/>
</Style>
</Setter.Value>
</Setter>
</MultiDataTrigger>
</Style.Triggers>
</Style>

When SNOOPing the offending rows of data which revert to black (randomly), I noticed that the CellValuePresenter properly had been triggered to the "InactiveInmate" foreground (whether or regular or alternating row), but within it, the PART_EditorSite (ContentPresenter) was randomly appearing with TextElement.Foreground = #FF00000 (black) and thus the XamTextEditor within it inherited this black rather than the "InactiveInmate" foreground from the CellValuePresenter.

NOTE: If I would simply hit my button which would re-bind to the same data, the black and grey (InactiveInmate) rows would just randomly change as I kept banging on the button.  Sometimes PART_EditorSite would respect the inherited "InactiveInmate" color from CellValuePresenter, and other times it would be Black (#FF00000).

The randomness of this occurrence leads me to believe it's not related to any potential style changing on our part elsewhere.

Parents
No Data
Reply
  • 155
    posted

    NOTE: When I change the FieldLayoutSettings back to HighlightAlternateRecords="False", this problem does not occur.  However, as soon as I revert this property back to "True", the randomness of different rows appearing black (not respecting the style) or grey (respecting the style) starts occurring, and it occurs on both alternating rows and "regular" rows.

Children