Applying same interaction trigger to multiple TextBoxes

前端 未结 2 1668
北恋
北恋 2021-01-24 07:57

I have multiple textboxes bound to different data, but I would like every one to launch the same command when the TextChanged event is fired. I could copy the interaction line u

2条回答
  •  春和景丽
    2021-01-24 08:38

    If your UpdateMode is always going to be PropertyChanged then there really isn't any reason not to listen to your own PropertyChangedEvent in your ViewModel. It will definitely improve testability.

        private void OnPropertyChanged(object sender, PropertyChangedEventArgs args)
        {
            switch (args.PropertyName)
            {
                case "Prop1":
                case "Prop2":
                    .
                    .
                    .
                    DataChangedCommand.Execute(null);
                    break;
            }
        }
    

提交回复
热议问题