-4

How to disable a button until another button is clicked in WPF MVVM ?

any solution ?

  • In the other button click event handler just write `buttonToBeDisabled.IsEnabled = false;` – Michał Turczyn Dec 13 '19 at 06:53
  • 3
    If you're using MVVM you can simply set the ```CanExecute``` property to false. If bound correctly, your button will be disabled. – devsmn Dec 13 '19 at 07:02
  • Please add some code. Did you bind the button to a command? – Fildor Dec 13 '19 at 07:03
  • Does this answer your question? [WPF MVVM: How to disable clicked button and enable all other buttons?](https://stackoverflow.com/questions/52035045/wpf-mvvm-how-to-disable-clicked-button-and-enable-all-other-buttons) – Circle Hsiao Dec 13 '19 at 07:04

1 Answers1

1

What was suggested in one of the comments: How to disable a button until another button is clicked in WPF MVVM is a possible solution, however it's not MVVM and it does quite opposite to what you want to achieve.

You can also do the following:

  • define a dependency property IsAnotherButtonClicked in your code and set it to false
  • bind a button's .IsEnabled property to the defined dependency property in XAML
  • in another button's Click event handler make sure that you set the IsAnotherButtonClicked to true
Mike
  • 1,225
  • 10
  • 21