views:

34

answers:

1

Hi Guys

I have a read only control that displays a calculation from other information in a datagrid. The binding it has works as far as displaying updated data as cell entries are made.

I do need to show visually when the calculation is above a given threshold. It is a read-only control (label, actually) though. How can I go about doing this?

Cheers,
Berryl

+1  A: 

if there is a calculation object that has properties such as IsOutsideRange (to display validation) and CalculationText (to display the text) then you could use a DataTrigger as so, the label's datacontext would be set to the calculation object

  <Label Text="{Binding Path=CalculationText}">
     <Label.Style>
        <Style
           BasedOn="{StaticResource {x:Type Label}}"
           TargetType="{x:Type Label}">
           <Style.Triggers>
              <DataTrigger
                 Binding="{Binding Path=IsOutsideRange}"
                 Value="True">
                 <Setter
                    Property="Background"
                    Value="Red" />
              </DataTrigger>
           </Style.Triggers>
        </Style>
     </Label.Style>
  </Label>
Aran Mulholland
Hi Aran - nice to see you. Yeah, I was so wrapped up in Validation as the only solution I hadn't investigated conditional formatting. Cheers
Berryl