WPF/MVVM: Disable a Button's state when the ViewModel behind the UserControl is not yet Initialized?

前端 未结 2 1270
臣服心动
臣服心动 2020-12-31 14:57

I have a DocumentListView.Xaml with a ListBox and 3 Buttons.

Behind that UserControl sits a DocumentListViewModel with 3 Buttons and their Command Property bound to

2条回答
  •  礼貌的吻别
    2020-12-31 15:15

    This is an interesting situation. Honestly I've never run into the case where the UI was loaded and interactive but the ViewModel was not yet bound.

    However, ignoring that for a moment, you could potentially use a FallbackValue on your binding to bind to a globally available NullCommand or something that always returns false for its CanExecute method.

提交回复
热议问题