private void CreateCommand()
{
if (_Execute == null)
throw new Exception("The method supplied for the Command does not exist. Check spelling.");
var notifier = _ViewModel as INotifyPropertyChanged;
if (notifier == null)
{
var dataContext = _ViewModel as IDataContext<object>;
if (dataContext != null)
{
notifier = dataContext.DataContext as INotifyPropertyChanged;
}
}
if (notifier != null && _CanExecute != null)
{
notifier.PropertyChanged += (s, e) =>
{
if (e.PropertyName == _CanExecute.Name)
OnCanExecuteChanged();
};
}
}