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

 

posted @ 2012-06-14 22:11  Ken-Cai  阅读(223)  评论(0)    收藏  举报