Откройте диалог с MVVM ⇐ C#
-
Гость
Откройте диалог с MVVM
I'm trying to show a dialog window when something throws an error in my application. When the viewmodel wants to launch a dialog, it fires an event and the View's code behind answers by creating a new Dialog window and showing it. The problem that I have is that I cannot pass any info to the dialog (like the error message), because the DialogViewModel isn't loaded when I create the DialogView.
I tried this on the DialogView constructor:
public DialogView() { InitializeComponent(); var vm = (DialogViewModel)DataContext; if( vm != null ) { vm.ErrorInfo= "Sample error message"; } } but this doesn't work because the DialogViewModel is null.
Источник: https://stackoverflow.com/questions/781 ... -with-mvvm
I'm trying to show a dialog window when something throws an error in my application. When the viewmodel wants to launch a dialog, it fires an event and the View's code behind answers by creating a new Dialog window and showing it. The problem that I have is that I cannot pass any info to the dialog (like the error message), because the DialogViewModel isn't loaded when I create the DialogView.
I tried this on the DialogView constructor:
public DialogView() { InitializeComponent(); var vm = (DialogViewModel)DataContext; if( vm != null ) { vm.ErrorInfo= "Sample error message"; } } but this doesn't work because the DialogViewModel is null.
Источник: https://stackoverflow.com/questions/781 ... -with-mvvm
Мобильная версия