zoukankan      html  css  js  c++  java
  • Silverlight Binding之ConverterParameter

    验证内容:
         Binding对象的ConverterParameter参数值是否有自动的时间通知,
    即该变量来与一个实现INotifyPropertyChanged接口且在改变时发出改变通知的属性,当该属性改变时,
    Binding对象的ConverterParameter是否会发生变化。
    实现步骤: 

      第一步创建一个简单的对象:

    View Code
     
      第二步创建一个集成自IValueConverter接口的对象

    View Code

      

        第三步创建Binding对象,比用Timer定期改变其属性。
    View Code
     
     public partial class MainPage : UserControl
        {
            System.Windows.Threading.DispatcherTimer timer 
    = new System.Windows.Threading.DispatcherTimer();
            Person person 
    = new Person();
            Random random 
    = new Random();
            
    public MainPage()
            {
                InitializeComponent();
                person.Name 
    = "-1";
                AlarmColorConvert convert 
    = new AlarmColorConvert();
                Binding binding 
    = new Binding();
                binding.Path 
    = new PropertyPath("Age"new object[0]);
                binding.Source 
    = person;
                binding.Converter 
    = convert;
                binding.ConverterParameter 
    = person.Name;
                LayoutRoot.SetBinding(Grid.BackgroundProperty, binding);
                timer.Interval 
    = TimeSpan.FromSeconds(5);
                timer.Tick 
    += new EventHandler(timer_Tick);
                timer.Start();
            }

            
    void timer_Tick(object sender, EventArgs e)
            {
                person.Age 
    = random.Next(0100);
                person.Name 
    = person.Age.ToString();

            }
     实验结论:无论上面person对象的Age和Name如何改变AlarmColorConvert接口的parameter值始终为-1.
     即:ConverterParameter值得改变时是不会自动传递的。
     
  • 相关阅读:
    ffmpeg解码视频存为BMP文件
    iphoneOS与Windwos下RTSP服务器与客户端的搭建
    RTSP协议介绍
    还原数据库
    .NET导入Excel数据
    jquery对表单元素操作
    Jquery操作select
    The process cannot access the file '' because it is being used by another process.....
    aspnet_merge.exe”已退出,代码为1的错误
    vs2008运行正常(可以访问数据库),而iis不能正常访问数据库
  • 原文地址:https://www.cnblogs.com/wangn/p/2181079.html
Copyright © 2011-2022 走看看