zoukankan      html  css  js  c++  java
  • WPF 绑定到静态属性(4.5)

    1. 声明静态事件

            /// <summary>
            /// 静态属性通知
            /// </summary>
            public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged;

    2.静态属性 setter

            private static bool _IsConnectSeccess;
            /// <summary>
            /// 是否连接成功
            /// </summary>
            public static bool IsConnectSeccess
            {
                get { return _IsConnectSeccess; }
                set
                {
                    _IsConnectSeccess = value;
                    StaticPropertyChanged?.Invoke(null,new PropertyChangedEventArgs(nameof(IsConnectSeccess)));
                }
            }

    3. xmal    这里比较重要, 要加括号  不然不能正常通知  甚至编译时异常 T-T

            <Border Name="CommunicationStatuBorder" IsHitTestVisible="False" Background="{Binding Path=(siemens:SiemensConnection.IsConnectSeccess) ,UpdateSourceTrigger=PropertyChanged,ConverterParameter='false,#90FF0000 true,#00000000',Converter={StaticResource comct}}"/>

    4.  只有.net frameWork 4.5以上才有这个功能, 

  • 相关阅读:
    js交互数据
    js字符串操作
    js数组操作
    hasattr ,setarrt, getattr属性
    装饰器
    redis数据库安装
    ubuntu中mysql数据库安装与删除
    装换器
    jinjia2
    Laravel框架与ThinkPHP框架的不同
  • 原文地址:https://www.cnblogs.com/nocanstillbb/p/10547960.html
Copyright © 2011-2022 走看看