打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
WPF绑定,后台数据已更新,但前台数据未刷新

1.后台模型类(一般定义主窗口类MainWindow的后台模型类MainWindowModel)中增加命令空间引用using System.ComponentModel;

2.修改类MainWindowModel继承INotifyPropertyChanged,定义事件PropertyChanged;

3.修改被前台绑定的属性set值。

具体参见如下代码:

public class MainWindowModel:INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        #region MES状态
        private string _MESState = "离线";
        /// <summary>
        ///
        /// </summary>
        public string MESState
        {
            get { return _MESState; }
            set
            {
                if (_MESState != value)
                     _MESState= value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("MESState"));
            }
        }
        #endregion

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
wpf list<T>与ObservableCollection<T>的区别
WPF自学笔记之
闲话WPF之十五(WPF的数据处理 [2])
WPF进阶之接口:INotifyPropertyChanged,ICommand
Data Binding和INotifyPropertyChanged是如何协调工作的?
Silverlight 4 数据绑定
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服