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
70
applying style DataRecordCellArea dynamically
posted

I have a list of objects implementing INotifyPropertyChange bound to a Grid (particularly CSLA objects).  One of the properties is called IsValid and responds true if there is any error on the object.

 I've applied the following style

<Style TargetType="{x:Type igDP:DataRecordCellArea}">

<Style.Triggers>

<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Record.DataItem.IsValid, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" Value="False">

<Setter Property="Background" Value="Red" />

<Setter Property="FontWeight" Value="Bold" />

</DataTrigger>

<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Record.DataItem.IsValid}" Value="True">

<Setter Property="Background" Value="Green" />

</DataTrigger>

</Style.Triggers>

</Style>

 I also have a textbox outside of the grid bound to a field of the active record.  When I put invalid data in this field, I can see the grid update with the same info, but it doesn't trigger the red background.  If I scroll the record out of view and back into view, it then displays a red background.  How do I set it up to display the red background when the data becomes invalid?

 

Parents Reply Children