I am using Binding to define three different colors to fill an ellipse
So to do that in my binding, I have used converter that contains an Enum
According to the enum returned, the fill color is changed
Some of my XAML :
<Ellipse Name="SignalStatus" Height="16" Width="16" Margin="29,35,14.2,68.2">
<Ellipse.Style>
<Style TargetType="Ellipse">
<!--<Setter Property="Fill" Value="Red"/> -->
<Style.Triggers>
<!--SignalStatus "Unknown" -->
<DataTrigger Binding="{Binding SignalStatus, Converter={StaticResource IntToSignalStatus} }" Value="Unknown">
<Setter Property="Fill" Value="Magenta"/>
</DataTrigger>
<!--SignalStatus "Permissive" -->
<DataTrigger Binding="{Binding SignalStatus, Converter={StaticResource IntToSignalStatus} }" Value="Permissive">
<Setter Property="Fill" Value="Green"/>
</DataTrigger>
<!--SignalStatus "Restrictive" -->
<DataTrigger Binding="{Binding SignalStatus, Converter={StaticResource IntToSignalStatus} }" Value="Restrictive">
<Setter Property="Fill" Value="Red"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Ellipse.Style>
</Ellipse>
Converter:
public class IntToSignalStatus : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
return SignalStatus.Unknown;
switch (value.ToString())
{
case "0":
return SignalStatus.Restrictive;
case "1":
return SignalStatus.Permissive;
default:
break;
}
return PlatformSkip.Unknown;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
In the specification docs they want the Red color to be set on the control by default.
How can I define a default fill color ( the Red one) for my ellipse ?
PS: I'm beginner en WPF & C# Programming
PermissiveStatus in the converter