Hi,
I am going to make a Label to change its Text and TextColor in different condition
Here is the XAML code of the Label
<Label Grid.Column="1" Text="No Preference" TextColor="Black" HorizontalOptions="FillAndExpand" HorizontalTextAlignment="End"> <Label.Triggers> <DataTrigger TargetType="Label" Binding="{Binding PropertyType}" Value="{x:Static enum:Types.House}"> <Setter Property="Text" Value="House"/> <Setter Property="TextColor" Value="Red"/> </DataTrigger> <DataTrigger TargetType="Label" Binding="{Binding PropertyType}" Value="{x:Static enum:Types.Flat}"> <Setter Property="Text" Value="Flat"/> <Setter Property="TextColor" Value="Blue"/> </DataTrigger> </Label.Triggers> </Label>
PropertyType is a enum variable and the enum is
public enum Types{ None = 0, House = 1, Flat = 2 }
So when I init the UI, the default PropertyType is Types.None (0), it is fine.
Then I do below changes and some unexpected results come out.
1. Change from "None" to "House", it also working fine that the UI show "House" in red.
2. Then I change from "House" to "Flat". It also working fine.
3. Change from "Flat" to "House". The UI shows "No Preference" in Red.
The DataTrigger only changes some parts but not all.
My device is Google Pixel 3 but I think the same issue may occur in iOS also.
Xamarin Form version 4.7.0.1239
Attached the sample app