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
转载于:https://www.cnblogs.com/Ken-Cai/archive/2012/06/14/2549921.html
359




被折叠的 条评论
为什么被折叠?



