How does one “disable” a button in WPF using the MVVM pattern?

前端 未结 5 1594
陌清茗
陌清茗 2020-12-03 10:33

I\'m trying to get a grasp on WPF and MVVM and have been making good progress. The WPF and MVVM side of things are going well.

However, the XAML and data binding sid

5条回答
  •  难免孤独
    2020-12-03 10:58

    This works too:

    View:

            
    

    ViewModel:

        private bool _btnEnabled;
        public bool btnEnabled
        {
            get { return _btnEnabled; }
            set
            {
                if (_btnEnabled != value)
                {
                    _btnEnabled = value;
                    OnPropertyChanged();
                }
            }
        }
    

提交回复
热议问题