Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Possible bug with DataTriggers in XAML?

$
0
0

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.


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>