vb.net - Passing Parameters from one view model to another in wpf -


I continue to adapt to the new world of WPF and MVVM I myself another problem which is a Vexing seems to be small with proven.

If I need a new form to take a parameter, then I have just passed the information required for the constructor of that form. Winforms is essentially a code behind the model anyway as it was not an issue.

Now I find myself with the control by a MainWindow (MainWindowViewModel) and English (controlled by LoginViewModel) which is shown as the first one dialog. I have resolved the issues of the missed dialogue and I can get the main window to show after locking the login dialog

The login dialog has been shown and the application with the following code in the startup Has responded to.

  Dim dlg new login dlg.ShowDialog () = then as it ended the truth Otherwise Current.Shutdown (0) is  

And I use the following to take care of showing the main window when the login window is closed; in the code behind the login window;

  Public sub new 'This caller is required by the designer InitializeComponent () Add any start after the' InitializeComponent () call. Application.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown End Sub Protected Overrides Sub OnClosed (e As EventArgs) MyBase.OnClosed (e) Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose End Sub  

now MainWindow you already know that it passed because I want to pass LoginViewModel to set it when it designed the mix DataContext MainWindoViewModel that, then how is a parameter that I MainWindowViewModel?

I can read c # but if possible I would like VB. I know that it is something that I would like to do this often, if there is a normal way to do this, then the way I Want to go

Thank you

Mvivim frameworks generally any type of messaging system So that the data can be transferred between view-models or sometimes between the view modal and the view.

The way you can handle messaging in more popular frameworks such as MvvmLight or MvvmCross, it is usually like an incident that uses a weak reference to prevent tight coupling, So that you can register for any type of message and then with any other view-model you can publish a message to any registered audience.

Your own messenger needs to be implemented, or it may now be a time to start using third-party structures, unless you have a specific reason to avoid it. Be there


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -