zoukankan      html  css  js  c++  java
  • WPF绑定RadioButton的标准做法

    枚举:

    enum EnumRadio
    {
      否,是
    }

    转换器:

     1 [ValueConversion(typeof(EnumRadio), typeof(bool))]
     2     class EnumRadioConverter : IValueConverter
     3     {
     4         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
     5         {
     6             return value == null ? false : value.Equals(parameter);
     7         }
     8 
     9         public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    10         {
    11             return value != null && value.Equals(true) ? parameter : Binding.DoNothing;
    12         }
    13     }

    Xaml:

    <model:EnumRadioConverter x:Key="EnumRadioConverter"/>
    
    
    <RadioButton GroupName="secondLoop" Content="" IsThreeState="False" IsChecked="{Binding HouseConfig.HouseStep2.IsAccumulation, Converter={StaticResource EnumRadioConverter}, ConverterParameter={x:Static model:EnumRadio.是}}" VerticalAlignment="Center"/>
                                                <RadioButton GroupName="secondLoop" Content="" IsThreeState="False" IsChecked="{Binding HouseConfig.HouseStep2.IsAccumulation, Converter={StaticResource EnumRadioConverter}, ConverterParameter={x:Static model:EnumRadio.否}}" VerticalAlignment="Center" Margin="20,0"/>
                                            

    引用:https://www.cnblogs.com/xpvincent/p/10267320.html

  • 相关阅读:
    [Linux]-配置多台机器的SSH相互信任
    [Linux]-常用代码块
    [Linux]-Shell编程与规范
    [Sqoop]-任务
    [Sqoop]-导入导出
    [Sqoop]-认识&部署
    [Hive]-函数篇
    Tomcat catalina.out日志使用log4j按天分割
    技术站点
    Linux监控命令
  • 原文地址:https://www.cnblogs.com/usen521/p/15320229.html
Copyright © 2011-2022 走看看