Possible bug with DataTriggers in XAML?

NandoCovoneNandoCovone USMember
edited May 2015 in Xamarin.Forms

If I bind the Color of a BoxView to a user defined property (say an enum type), and then use a Converter to specify which color to use, based on the property set, the color is applied every time the property is modified.

However, the same cannot be said when DataTriggers are used.

The BoxView's color is not always applied.

Is there something wrong in how the DataTriggers are set, or could this be a possibly bug?

  <BoxView WidthRequest="150" HeightRequest="50">
    <BoxView.Triggers>
      <DataTrigger TargetType="BoxView" Binding="{Binding Path=StateProperty}" Value="{x:Static local:StateProperty.Lost}">
        <Setter Property="Color" Value="Pink" />
      </DataTrigger>
      <DataTrigger TargetType="BoxView" Binding="{Binding Path=StateProperty}" Value="{x:Static local:StateProperty.Present}">
        <Setter Property="Color" Value="Purple" />
      </DataTrigger>
      <DataTrigger TargetType="BoxView" Binding="{Binding Path=StateProperty}" Value="{x:Static local:StateProperty.PresentNoResponse}">
        <Setter Property="Color" Value="Teal" />
      </DataTrigger>
    </BoxView.Triggers>
  </BoxView>

The color will change but not always.
The binding context is correctly set, and the StateProperty does in fact fire a PropertyChanged event.

Can anyone provide any insight?

Thanks.

Tagged:

Posts

  • NandoCovoneNandoCovone USMember

    Not sure what happened to the XAML code, but here it is again.


    <BoxView.Triggers>









    </BoxView.Triggers>

Sign In or Register to comment.