zoukankan      html  css  js  c++  java
  • 多属性绑定,并转换类型

    例子1:

    //暂时不用,多条件转换
      public class CoordinateToMapPoint : IMultiValueConverter
      {
          ////Xaml绑定多个
          //MultiBinding multiBinding = new MultiBinding();
          ////
          //Binding bd1 = new Binding();
          //bd1.Path = new PropertyPath("Jqinfox");
          //bd1.Source = alarm;
          //multiBinding.Bindings.Add(bd1);
          ////
          //Binding bd2 = new Binding();
          //bd2.Path = new PropertyPath("Jqinfoy");
          //bd2.Source = alarm;
          //multiBinding.Bindings.Add(bd2);
          ////
          //multiBinding.Converter = new CoordinateToMapPoint();

          public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
          {
              string strJqinfox = values[0].ToString();
              double dJqinfox;
              double.TryParse(strJqinfox, out dJqinfox);
              //
              string strJqinfoy = values[1].ToString();
              double dJqinfoy;
              double.TryParse(strJqinfoy, out dJqinfoy);
              //
              return new MapPoint(dJqinfox, dJqinfoy);
          }

          public object ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
          {
              throw new NotImplementedException();
          }
      }

    例子2:

    <Rectangle Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="3" Stroke="Black">
    <Rectangle.Fill>
    <MultiBinding Converter="{StaticResource ResourceKey=rgbConverter}">
    <Binding ElementName="slider_R" Path="Value"/>
    <Binding ElementName="slider_G" Path="Value"/>
    <Binding ElementName="slider_B" Path="Value"/>
    </MultiBinding>
    </Rectangle.Fill>
    </Rectangle>

  • 相关阅读:
    实验室 Linux 集群的管理常用命令
    python操作MySQL数据库
    python 文件操作总结
    MySQL常用的操作整理
    机器学习模型数据结构:logistic regression, neural network, convolutional neural network
    Python并发编程之线程池/进程池--concurrent.futures模块
    python3.5实现购物车
    Centos上安装python3.5以上版本
    [Python]关于return逻辑判断和短路逻辑
    [Python]返回函数,装饰器拾遗
  • 原文地址:https://www.cnblogs.com/changbaishan/p/3374150.html
Copyright © 2011-2022 走看看