I have binding on some command:
<Button Command="{Binding Save}" />
Save is command of some object that can be selected from list. In initial state there is no any selected object so binding does not work and CanExecute does not invoked. How can i disable this button using MVVM?
Solution: WPF/MVVM: Disable a Button's state when the ViewModel behind the UserControl is not yet Initialized?
Guys, thanks for your answers and sorry for duplication of question.
Define a command that always return false to CanExecute. Declare it at a global position such as in your App.Xaml. you can specify this empty-command then as the FallbackValue
for all your command bindings you expect a null value first.
<Button Command="{Binding Save,FallbackValue={StaticResource KeyOfYourEmptyCommand}}" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With