Thursday 15 March 2012

mvvm - Managing multiple WPF views in an application -


So I have noticed that a navigation service exists in WPF to maintain a flow through an application. I'm not really in the market for back and forward type functionality, I'm just looking for a good way to switch between views when a button is pressed on a particular scene. I am using MVVM, so I'm not sure if I can give App.xaml.cs a copy of each scene or view modal and switch to a View Model command in App.xaml.cs Call me Maybe I should just handle the click event on the button and taste some of it. Close (); NewWindow.Show ();
With so many things in WPF, this one is not comfortable for me, though there are probably some simple solutions.

Thank you!

I have created a "window loader" class which is the app class immediately when the application starts . The window loader has a dictionary that maintains a union of model model types and looks at types, there is also a way in which the visual model takes a look, depending on the type of visual model the scene solves. , Gives the scene instantaneous, sets the viewcondent of the datacentext into the visual model, so it shows the window loader also registers in the visual model for an event that closes the window Not when it is picked up.

The window loader implements an IWindowLoader interface and a reference to it is kept in each view model (when the window loader instantly provides a visual model for a public IWindowLoader property in the visual model) . Therefore any other visual model can be shown without knowing about any visual model and without showing itself. In addition, window loaders can be fun to test easily.

When I went through the same process, now I have found many examples of this basic basic method. I've just finished rolling out.


No comments:

Post a Comment