viewmodellocator

Exiting an App or Closing a Control When Using MVVM

心已入冬 提交于 2019-12-02 11:48:56
In my WPF application, I am using the ViewModelLocator without IoC. I am calling the static ViewModelLocator.Cleanup() method provided by the MVVM-Light framework from my own button which is tied to a "close window command". This Command calls the static ViewModelLocator.Cleanup() , which calls an instance Cleanup() method on my MainWindowViewModel instance. The instance Cleanup() method then sets the property to which the MainWindow binds its DataContext , to null. The setter on the property raises a PropertyChanged event. Curiously, setting this property to null does not cause the window to

Prism 6.1 ViewModelLocator doesn't instantiate my ViewModel

我是研究僧i 提交于 2019-12-02 04:50:47
I just set up a new project recently, using Prism 6.1(with Unity). I've my bootstrapper: public class ServerBootstrapper : UnityBootstrapper { protected override DependencyObject CreateShell() { return Container.Resolve<MainShell>(); } protected override void InitializeShell() { base.InitializeShell(); Application.Current.MainWindow = (Window)Shell; Application.Current.MainWindow.Show(); } protected override void ConfigureModuleCatalog() { base.ConfigureModuleCatalog(); ModuleCatalog catalog = (ModuleCatalog)ModuleCatalog; catalog.AddModule(typeof(ServerUIModule)); } } The MainShell: <Window

MvvmCross ViewModel caching and re-initializing

醉酒当歌 提交于 2019-12-01 06:00:47
I need to be able to intercept the framework and perform so re-initialization when a ViewModel is being reloaded from the cache. Since the ViewModel is not being recreated, I can neither use the Init(), MvxViewModel.InitFromBundle, nor MvxViewModel.ReloadFromBundle methods. I am trying to debug a situation where clicking on the back button restores a ViewModel with inconsistent state. Some sort of MvxViewModel.OnReloading() would help. Is there a way to do this in v3? EDIT: Assume I have FirstPageViewModel which exposes a command to navigate to SecondPageViewModel. Based on what I am observing

What is a ViewModelLocator and what are its pros/cons compared to DataTemplates?

本小妞迷上赌 提交于 2019-11-26 14:58:19
Can someone give me a quick summary of what a ViewModelLocator is, how it works, and what the pros/cons are for using it compared to DataTemplates? I have tried finding info on Google but there seems to be many different implementations of it and no striaght list as to what it is and the pros/cons of using it. Intro In MVVM the usual practice is to have the Views find their ViewModels by resolving them from a dependency injection (DI) container. This happens automatically when the container is asked to provide (resolve) an instance of the View class. The container injects the ViewModel into

What is a ViewModelLocator and what are its pros/cons compared to DataTemplates?

旧街凉风 提交于 2019-11-26 05:57:23
问题 Can someone give me a quick summary of what a ViewModelLocator is, how it works, and what the pros/cons are for using it compared to DataTemplates? I have tried finding info on Google but there seems to be many different implementations of it and no striaght list as to what it is and the pros/cons of using it. 回答1: Intro In MVVM the usual practice is to have the Views find their ViewModels by resolving them from a dependency injection (DI) container. This happens automatically when the