zoukankan      html  css  js  c++  java
  • 【Controls】【RadioButton】Radio Button绑定

    Radio Button绑定

     

    转换器


        public class IsPublishConverter : IValueConverter
        {
            
    public object Convert(object value, Type targetType,
                                  
    object parameter, CultureInfo culture)
            {
                
    string a = value.ToString();
                
    string b = parameter.ToString();

                
    if (a == b)
                    
    return true;
                
    else
                    
    return false;
            }

            
    public object ConvertBack(object value, Type targetType,
                                      
    object parameter, CultureInfo culture)
            {
                
    string a = value.ToString();
                
    string b = parameter.ToString();

                
    if (a == b && b == "True")
                    
    return true;
                
    else if(a==&& b=="1")
                    
    return true;
                
    else
                    
    return false;
            }

        }



    界面xaml中


    <UserControl.Resources>资源中加入
       
    <my:IsPublishConverter x:Key="myConverter" />
    </UserControl.Resources>


    界面元素
      
    <StackPanel Margin="5" Orientation="Horizontal">
          
    <RadioButton Content="共享" Margin="7,0,0,0" GroupName="1" IsChecked="{Binding Path=SelectFilter.FilterMode, Mode=TwoWay, 
                       Converter={StaticResource myConverter},
                       ConverterParameter
    =1}"/>
          <RadioButton Content="私有" Margin="7,0,0,0" GroupName="2" IsChecked="{Binding Path=SelectFilter.FilterMode, Mode=TwoWay, 
                       Converter={StaticResource myConverter},
                       ConverterParameter
    =0}"/>
      </StackPanel>
      
    <TextBlock Margin="5" Text="过滤器类型:" />
      
    <StackPanel Margin="5" Orientation="Horizontal">
          
    <RadioButton Content="上报" Margin="7,0,0,0" GroupName="3" IsChecked="{Binding Path=SelectFilter.FilterType, Mode=TwoWay, 
                       Converter={StaticResource myConverter},
                       ConverterParameter
    =True}"/>
          <RadioButton Content="过滤" Margin="7,0,0,0" GroupName="4" IsChecked="{Binding Path=SelectFilter.FilterType, Mode=TwoWay, 
                       Converter={StaticResource myConverter},
                       ConverterParameter
    =False}"/>
      </StackPanel>



  • 相关阅读:
    管理培训笔记
    Jhipster Registry(Eureka Server) Docker双向联通与高可用部署
    (转阮一峰)深入理解OAuth 2.0
    基于spring security 实现前后端分离项目权限控制
    spring security实现动态配置url权限的两种方法
    Spring Security 架构与源码分析
    开源APM系统skywalking介绍与使用
    Angular 中后台前端解决方案
    SpringBoot+Security+MyBatis+ES+MQ+Redis+Docker+Vue的电商系统
    Jenkins+GitLab+Docker+SpringCloud实现可持续自动化微服务
  • 原文地址:https://www.cnblogs.com/ningth/p/1837307.html
Copyright © 2011-2022 走看看