Questions tagged [mvvm-light]

The MVVM Light Toolkit is a set of components helping people to get started with the Model - View - ViewModel pattern in Silverlight, WPF, Xamarin, .NET Core and Windows Phone. It is a light and pragmatic framework that contains only the essential components needed.

The MVVM Light Toolkit is a set of components helping people to get started with the Model - View - ViewModel pattern in Silverlight, WPF, Xamarin, .NET Core and Windows Phone. It is a light and pragmatic framework that contains only the essential components needed.

The main purpose of the toolkit is to accelerate the creation and development of MVVM applications in WPF, Xamarin, .NET Core, Silverlight and Windows Phone.

Like other MVVM implementations, the toolkit helps users to separate the View from the Model which creates applications that are cleaner and easier to maintain and to extend. It also creates testable applications and allows to have a much thinner user interface layer (which is more difficult to test automatically).

More information about the MVVM Light Toolkit can be found on http://www.galasoft.ch/mvvm .

Currently there are versions for .Net 4.5, 4 & 3.5 and a portable version as well.

2856 questions
33
votes
2 answers

MVVM Light Messenger - Sending and Registering Objects

Could somebody be kind enough to give me an example of how to Send and Register custom objects between classes using MVVM Light's Messenger or point me to a tutorial that covers this (preferably a concrete example)? I've been trying to use Messenger…
Jason D
  • 2,634
  • 6
  • 33
  • 67
30
votes
2 answers

When to use events over commands in WPF?

Hi i have recently looked into WPF and started learning about Events and Commands. I typically use Commands on Button clicks which causes a method to Run in my "view model". Is it possible to make the Button react to any other events like the…
CAA
  • 355
  • 3
  • 5
30
votes
5 answers

MVVM load data during or after ViewModel construction?

My generic question is as the title states, is it best to load data during ViewModel construction or afterward through some Loaded event handling? I'm guessing the answer is after construction via some Loaded event handling, but I'm wondering how…
mkmurray
  • 2,434
  • 3
  • 21
  • 22
29
votes
10 answers

How to reference a generic type in the DataType attribute of a DataTemplate?

I have a ViewModel defined like this: public class LocationTreeViewModel : ObservableCollection, INotifyPropertyChanged TTree : TreeBase I want to reference it in the DataType attribute of a DataTemplate in XAML.…
mahboub_mo
  • 2,908
  • 6
  • 32
  • 72
26
votes
3 answers

MVVM Light 5.0: How to use the Navigation service

In the latest release of MVVM Light note, it has been indicated that MVVM Light now provides a "Navigation Service". But myself and my friend google are unable to find how to use it. I can see that I can ask a INavigationService to the…
J4N
  • 19,480
  • 39
  • 187
  • 340
24
votes
2 answers

How to use RelayCommand with the MVVM Light framework

I've just started learning the MVVM Light framework and I can't find any straightforward examples on how to use a RelayCommand. For purposes of learning, I'd just like to have a button in my view which when clicked show's a hello world world message…
Evan
  • 4,450
  • 10
  • 40
  • 58
24
votes
1 answer

What is the best way to switch views/usercontrols in MVVM-light and WPF?

I'm relatively new to WPF and MVVM and the hardest thing I have found is how to simply switch a usercontrol or a view in an application. In winforms, to have a control remove itself you would simple say …
JReed
  • 243
  • 1
  • 2
  • 5
23
votes
3 answers

Change Button Background color through MVVM pattern in WPF

I am using MVVM light with WPF. I want to set button background color based on some specific condition through ViewModel. Kindly suggest some way to get it. Thanks
Yogesh
  • 829
  • 2
  • 8
  • 21
23
votes
2 answers

Where are the MVVM Light snippets?

It seems that snippets of MVVM Light are not installed when we use Nuget to install MVVM Light Toolkit. Where can I find them ?
JYL
  • 8,228
  • 5
  • 39
  • 63
22
votes
3 answers

Where is the documentation for MVVM Light?

Is there documentation or a reference for the MVVM Light framework that let me know what is it capable of? After a lot of googling I've found very few things.
NestorArturo
  • 2,476
  • 1
  • 18
  • 21
22
votes
3 answers

Creating an MVVM friendly dialog strategy

I'm trying to create a strategy for handling popup forms for use throughout any part of my application. My understanding so far is that I will need a single UserControl in the root of my MainWindow. This will be bound to its own ViewModel which will…
mortware
  • 1,910
  • 1
  • 20
  • 35
22
votes
3 answers

Cleanup vs Dispose(bool) in MVVM-light

In the latest version of MVVM-light (V3 SP1) both "Dispose()" and "Dispose(bool)" methods in ViewModel class are marked Do not use this method anymore, it will be removed in a future version. Use ICleanup.Cleanup() instead Does this mean that…
Budda
  • 18,015
  • 33
  • 124
  • 206
22
votes
5 answers

WPF MVVM Get Parent from VIEW MODEL

In a MVVM WPF application. How do you set a second windows parent from the ViewModel? example: view1 -- viewModel1 viewModel1's command calls: var view2 = new view2 view2.Owner = <----This is the problem area. How do I get view1 as the owner here…
dnndeveloper
  • 1,631
  • 2
  • 19
  • 36
21
votes
4 answers

SimpleIoc - can it provide new instance each time required?

So far as I understand, SimpleIoc uses GetInstance method to retrieve an instance of a class that is registered. If the instance doesnt exist, it will create it. However, this instance is cached and always retrieved, which mimics the singleton…
Goran
  • 6,328
  • 6
  • 41
  • 86
21
votes
1 answer

MVVM SimpleIoc, how to use an interface when the interface implementation requires construction parameters

Using MVVM's SimpleIoc, I would like to register an implementation for a given interface, but the implementation requires one parameter in its constructor: public class MyServiceImplementation : IMyService { public MyServiceImplementation(string…
Berthier Lemieux
  • 3,785
  • 1
  • 25
  • 25