viewmodellocator

MVVMLight within another MVVMLight project

巧了我就是萌 提交于 2020-01-06 08:37:07
问题 I am working on a MVVMLight / WPF project and need to add a chunk of functionality which will include multiple views and viewmodels. I know this same bit of functionality will be used in other projects in the near future so I would like to make this functionality its own project that I can add to other solutions as needed wiuth little or no modification. I started by adding a second MVVMLight project (Beta), removing the standard MainWindow.xaml and MainViewModel.cs files and created a simple

Prism 6.1 ViewModelLocator doesn't instantiate my ViewModel

廉价感情. 提交于 2019-12-20 03:52:37
问题 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

Prism: ViewModelLocator creates the view model instance(s) but how can I target it?

喜你入骨 提交于 2019-12-12 03:44:39
问题 Is there a way whereby I can identify a ChildViewModel instance, which was created by prism's ViewModelLocator, upon opening it's corresponding window? I would like to trigger that the ChildViewModel should load it's data, based on parameters originating from the MasterViewModel. In code, in MasterViewModel has an ICommand in a which is responsible for requesting opening a new child window by publishing an event, and there is a corresponding subscriber. public ICommand OpenNewChildWindow() {

How to Register Multiple Interface Implementation In IoC in MvvmLight?

杀马特。学长 韩版系。学妹 提交于 2019-12-12 03:27:56
问题 Register Multiple Interface Implementation In LightInject IoC How to use MvvmLight's Ioc to solve the problem? I have multiple DataService (DataService1, DataService2, DataService3 ...). They are all IDataService and need to be contacted with multiple ViewModel. Mvvmlight can't do it: SimpleIoc.Default.Register<IDataService, DataService1>("DataService1Key"); SimpleIoc.Default.Register<IDataService, DataService2>("DataService2Key"); ... 回答1: You can also use 'class' key identifiers in

How to use a ViewModelLocator in a user control?

爷,独闯天下 提交于 2019-12-11 19:13:44
问题 I was asked to convert a standalone WPF application that uses the MVVM pattern into a user control. This app consists of a main window and a few other windows. However, I get a few errors when trying to do so all pointing to my App.xaml class and other resources declared like converters: Library project file cannot specify ApplicationDefintion element. The project file contains a property value that is not valid. The name "ViewModelLocator" does not exist in the namespace "clr-namespace

Cannot find resource named 'ViewModelLocator' exception

笑着哭i 提交于 2019-12-11 10:36:55
问题 I am trying to use ViewModelLocator by declaring it as a resource in App.xaml. Its a very simple class as follows: public class ViewModelLocator { public ShellViewModel ShellPage { get { return new ShellViewModel(); } } } App.xaml file is as below: <Application x:Class="SomeNamespace.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:vm="clr-namespace:SomeNamespace.ViewModels"> <Application.Resources> <vm

Register viewmodel in different project from main project viewmodellocatoe in mvvmlight

混江龙づ霸主 提交于 2019-12-10 10:21:34
问题 How do I register a viewmodel in a different referenced project in the ViewModelLocator class of MVVMLight. I keep getting an error when ever I try to use the SimpleIoc to register the viewmodel class because it's in a different project, and I'd Like to keep different projects for different parts of my application. 来源: https://stackoverflow.com/questions/14898301/register-viewmodel-in-different-project-from-main-project-viewmodellocatoe-in-mv

MVVM - Reuse Views with multiple ViewModels

為{幸葍}努か 提交于 2019-12-06 12:55:51
问题 I believe one of the main benefits of MVVM is decoupling, the binding and lack of references makes things a lot more reusable. All MVVM examples I find have some kind of View with a ViewModel with the same naming like ExampleView has a ExampleViewModel . And always a one to one relationship, one View, one ViewModel. But in my current project I have a form to be filled so data can be added to the data base, also the user has the option to edit the data on the data base, so this form View can

MvvmCross ViewModel caching and re-initializing

老子叫甜甜 提交于 2019-12-04 01:30:27
问题 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

Exiting an App or Closing a Control When Using MVVM

别等时光非礼了梦想. 提交于 2019-12-02 20:04:31
问题 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