码迷,mamicode.com
首页 > Windows程序 > 详细

WPF 绑定到静态属性(4.5)

时间:2019-03-17 18:24:11      阅读:559      评论:0      收藏:0      [点我收藏+]

标签:dev   false   重要   ati   ack   ret   eof   成功   framework   

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以上才有这个功能, 

WPF 绑定到静态属性(4.5)

标签:dev   false   重要   ati   ack   ret   eof   成功   framework   

原文地址:https://www.cnblogs.com/nocanstillbb/p/10547960.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!