public class EnumBooleanConverter : IValueConverter
{
#region IValueConverter Members
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
string parameterString = parameter as string;
if (parameterString == null)
return DependencyProperty.UnsetValue;
if (Enum.IsDefined(value.GetType(), value) == false)
return DependencyProperty.UnsetValue;
object parameterValue = Enum.Parse(value.GetType(), parameterString);
return parameterValue.Equals(value);
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
string parameterString = parameter as string;
if (parameterString == null)
return DependencyProperty.UnsetValue;
return Enum.Parse(targetType, parameterString);
}
#endregion
}
<StackPanel>
<StackPanel.Resources>
<local:ComparisonConverter x:Key="ComparisonConverter" />
</StackPanel.Resources>
<RadioButton IsChecked="{Binding Path=YourEnumProperty, Converter={StaticResource ComparisonConverter}, ConverterParameter={x:Static local:YourEnumType.Enum1}}" />
<RadioButton IsChecked="{Binding Path=YourEnumProperty, Converter={StaticResource ComparisonConverter}, ConverterParameter={x:Static local:YourEnumType.Enum2}}" />
</StackPanel>
Code Example |
---|
Csharp :: c# pass mouse events to parent |
Csharp :: 10x10 table matrix C# |
Csharp :: css text no word wrap |
Html :: You are running `create-react-app` 4.0.3, which is behind the latest release (5.0.0). |
Html :: html dollar symbol |
Html :: html input integer and positive |
Html :: link css to html |
Html :: boostrap row reverse utility |
Html :: html mailto |
Html :: cdk bootstrap |
Html :: materialize cdn |
Html :: print page button html |
Html :: registered symbol html |
Html :: tab in html |
Html :: how to add favicon in html |
Html :: box shadow svg css |
Html :: add space in html |
Html :: html5 pattern for numbers only |
Html :: font awesome reload icon |
Html :: html example |
Html :: fontawesome |
Html :: json placeholder limit |
Html :: ngclass else |
Html :: how to add an audio in html |
Html :: html links |
Html :: function to do when the html done loading |
Html :: dutch phone pattern html |
Html :: wave symbol |
Html :: crossorigin attribute values |
Html :: hint text html |