DataContext が xaml で初期化された MainViewModel であるという MainView を作成しました。
MainView には、MainViewModel の Content プロパティにバインドされた ContentControl が含まれています。
MainViewModel コンストラクターにいくつかのコンテンツを追加したので、現在のユーザーがログインしていない場合、LoginView (およびそれに対応する DataContext LoginViewModel) がこの Content プロパティに自動的に読み込まれます。
今私の質問は、ユーザーが正常にログインしたときに何をすべきかです:
'To be called from the LoginCommand
Private Sub Login
'Do Login
If WebContext.Current.User.IsAuthenticated Then
' - Publish a global event to be subscribed and caught from the MainViewModel
' - Close LoginView
' - The MainViewModel should set it's Content property back
' to what the user initially intended to open
End If
End Sub
これはどのように行われますか?
注:私EventAggregator
は他のものよりもプリズムのrathenを使用することを好みますが、手がかりがありません:
- ViewModel 間で展開する方法
- イベントの作成方法 (パラメーターを渡す必要も、一般的である必要もありません。ただ
Action
、LoginAction
パラメーターはありません。 - MainViewMode からサブスクライブするにはどうすればよいですか。
- MEF や Unity は使用せず、個別のモジュールも使用しません。アプリケーションはすべて 1 つのアセンブリに含まれています。
- コード ビハインドにコードをまったく記述しないことを好みます
- VB.NET または C# の両方で同じ回答を歓迎します
どんな助けもお勧めします