DataForm 中用 RadionButton
1. 使用Convertor
<RadioButton
Content="type 1"
IsChecked="{Binding Path=MyTypeProperty, Mode=TwoWay, Converter={StaticResource ConvertMyType}, ConverterParameter=type1}" />
<RadioButton
Content="type 2"
IsChecked="{Binding Path=MyTypeProperty, Mode=TwoWay, Converter={StaticResource ConvertMyType}, ConverterParameter=type2}" />
Your value converter :
public class ConvertMyType : IValueConverter
{
#region Methods
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value == null || parameter == null)
return value;
return value.ToString().Equals(parameter.ToString());
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value == null || parameter == null)
return value;
return parameter;
}
#endregion Methods
}
2 使用 ItemsControl
浙公网安备 33010602011771号