Questions tagged [viewmodellocator]
85 questions
119
votes
3 answers
What is a ViewModelLocator and what are its pros/cons compared to DataTemplates?
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…

Rachel
- 130,264
- 66
- 304
- 490
7
votes
1 answer
MVVMLight ViewModelLocator registering dataservice
This question might look naive, but I couldn't understand this code in the ViewModelLocator.cs file:
static ViewModelLocator()
{
ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
if (ViewModelBase.IsInDesignModeStatic)
{
…

Qirat
- 95
- 1
- 3
6
votes
3 answers
Passing parameter between ViewModels using MVVMLight
I'm having a problem to pass parameters betweeen my ViewModels using the Messenger class in the MVVMLight Framework.
This is the code I'm using :
ViewModelLocator
public ViewModelLocator ()
{
ServiceLocator.SetLocatorProvider(() =>…

Wassim AZIRAR
- 10,823
- 38
- 121
- 174
6
votes
2 answers
How to send parameters between viewmodels using viewmodellocator
I am creating a WPF application using MVVMLight. I use ViewModelLocator to create viewmodels.
My problem is passing parameters between them.
For example we have a situation:
We have a grid with some entities, when one of them is doubleclicked I…

Eugene
- 1,515
- 1
- 13
- 23
5
votes
1 answer
How to unit test using a ViewModelLocator
I've created a custom view model locator using Autofac and set it up normally through the App.xaml like most of them are usually used. My problem is how do I unit test now? I'm getting an error every time I try to test a method that initializes a…

TMan
- 4,044
- 18
- 63
- 117
5
votes
2 answers
MvvmCross ViewModel caching and re-initializing
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…

Klaus Nji
- 18,107
- 29
- 105
- 185
4
votes
1 answer
Multiple Instance ViewModels and the ViewModelLocator
I have built a ViewModelLocator using Unity and have been successfully using it with singleton ViewModel instances. For example:
public class ViewModelLocator
{
private static readonly UnityContainer Container;
static ViewModelLocator()
…

Kristian Wilson
- 93
- 1
- 1
- 6
4
votes
1 answer
How do you put your design time view model in a separate assembly?
I'm using MVVM Light and Prism with the view model locator pattern. I really like having a design time view model for use in Blend, but I don't necessarily want to ship it with my production code. Is there any way to put the design time view model…

Mike Post
- 6,355
- 3
- 38
- 48
4
votes
1 answer
How to clear data of ViewModel in MVVM Light xamrin?
I am working on Xamrin Form right now. I have problem with clear data of ViewModel.
When I logout and login with different user, it shows me data of previous user because the value of UserProfileViewModel doesn't get clear.
When user logout, I…

Developer
- 295
- 4
- 16
4
votes
2 answers
MVVM light application - how to properly clean ViewModels
I am working on a cookbook window application in WPF which consist of one window and several userControls that are replacing each other with relayCommands using messages from MVVM Light.
The application works with a DB that is generated from the…

Dracke
- 651
- 2
- 11
- 30
3
votes
1 answer
Simple MVVM Toolkit - loosing ViewModel when switching them
I'm using MVVM Toolkit.
In my ViewModels I'm keeping data which I'd like to save when switching ViewModel to another.
Responsible for switching ViewModels is ViewModelLocator:
http://simplemvvmtoolkit.codeplex.com/wikipage?title=Getting%20Started…

user983731
- 31
- 1
3
votes
2 answers
What is the preferred way to connect viewmodels to their views?
In the past while working with MVVM I've created every View as a DataTemplate to it's corresponding viewmodel to handle connecting them. I just started using MVVM Light, and noticed they have the ViewModelLocator. Several other toolkits I've…

Mark Featherston
- 33
- 1
- 3
3
votes
1 answer
Implementing own ViewModelLocator
I wanted to implement ViewModelLocator by my own. So I implemented the simplest app in the world. I did everything as in this tutorial. But I'm still getting an exception:
XamlParseException occured
Exception thrown:…

tobiasznowak
- 89
- 8
3
votes
3 answers
Resolve ViewModels in separated assembly with ViewModelLocator in Prism 6
I am trying to connect the DataContexts of my views to view models from another separated assembly.
Brian Lagunas wrote on his blog something to Getting Started with Prism’s new ViewModelLocator, However, his solution is specially to customize the…

SomeCode.NET
- 917
- 15
- 33
3
votes
1 answer
Unknown type 'ViewModelLocator' in XML namespace 'clr-namespace:namespaceblabla;assembly=blabla'
I'm buidling an Windows Phone 8.1 project and I'm using the MVVM Light Libraries only library.
I created a PCL project to hold my ViewModels so I can later use them for a Windows Store Project.
I followed along the guide…

timr
- 6,668
- 7
- 47
- 79