1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Text;
- using System.Windows.Controls;
- using System.Windows.Input;
- using Aitex.Core.UI.MVVM;
- using Aitex.Core.Util;
- using Aitex.Core.Utilities;
- namespace EfemDualUI.Controls.Common
- {
- public class ViewModelControl : UserControl, INotifyPropertyChanged, IViewModelControl
- {
- public event PropertyChangedEventHandler PropertyChanged;
- public void SubscribeKeys(SubscriptionViewModelBase baseModel)
- {
- baseModel.SubscribeKeys(this);
- }
- public void InvokePropertyChanged()
- {
- if (PropertyChanged != null)
- {
- var ps = this.GetType().GetProperties();
- foreach (var p in ps)
- {
- if (!p.GetCustomAttributes(false).Any(attribute => attribute is IgnorePropertyChangeAttribute))
- PropertyChanged(this, new PropertyChangedEventArgs(p.Name));
- if (p.PropertyType == typeof(ICommand))
- {
- if (p.GetValue(this, null) is IDelegateCommand cmd)
- cmd.RaiseCanExecuteChanged();
- }
- }
- }
- }
- }
- }
|