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>

  • 相关阅读:
    畅销书排行榜
    阿里云大数据产品体系
    天然气收费管理系统的研究与实现随笔
    Web端实现RTC视频特效的解决方案
    从0搭建在线聊天室,只需4步!
    技术干货 | JavaScript 之事件循环(Event Loop)
    C++20 四大特性之一:Module 特性详解
    Android Flutter 多实例实践
    网易云信线上万人连麦技术大揭秘
    Python + Pytest 自动化框架的用例依赖实操
  • 原文地址:https://www.cnblogs.com/changbaishan/p/3374150.html
Copyright © 2011-2022 走看看