prism vs mvvm light for wpf

I just moved a project from Prism to MvvmLight and it seems to work faster (very subjective). Both Prism and MvvmLight have Mediator realisation (IEventAggregator in Prism, IMessenger in MvvmLight). But IMessenger has more abilities (for instance, sending messages with tokens) compared to IEventAggregator and is much more convenient to use (see next item). MvvmLight … Read more

Implementing CollectionChanged

You have to add a PropertyChanged listener to each item (which must implement INotifyPropertyChanged) to get notification about editing objects in a observable list. public ObservableCollection<Item> Names { get; set; } public List<Item> ModifiedItems { get; set; } public ViewModel() { this.ModifiedItems = new List<Item>(); this.Names = new ObservableCollection<Item>(); this.Names.CollectionChanged += this.OnCollectionChanged; } void OnCollectionChanged(object … Read more

ViewModels in ViewModelLocator MVVM Light

First, lets look at what ViewModelLocator does and why we use it: ViewModelLocator is declared as an object on our App.xaml page and is an application singleton. We’re going to have one, and only one of them available to the application when it runs. ViewModelLocator is the source for all our ViewModels in MVVM Light. … Read more

MVVM, Unity, Prism, MEF, Caliburn – What should I use?

If you want to build an MVVM application (which you probably do for various advantages), then you want an MVVM framework. I would recommend Caliburn.Micro, as it is straightforward to implement following the examples on the Caliburn.Micro documentation page. It also has a very compelling convention over configuration mechanism, and uses an Actions system to … Read more

MVVM Light: Adding EventToCommand in XAML without Blend, easier way or snippet?

Suppose you use .NetFramework4: First add namespace: xmlns:cmd=”clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Platform” Syntax for the Loaded event. <i:Interaction.Triggers> <i:EventTrigger EventName=”Loaded”> <cmd:EventToCommand Command=”{Binding Mode=OneWay, Path=LoadedCommand}” PassEventArgsToCommand=”True” /> </i:EventTrigger> </i:Interaction.Triggers>

MVVM Light RelayCommand Parameters

I believe this will work: _projmenuItem_Edit = new RelayCommand<object>((txt)=>ProjEditNode(txt)); — EDIT — You’ll need to define your RelayCommand with the type as well: e.g. public RelayCommand<string> myCommand { get; private set; } myCommand = new RelayCommand<string>((s) => Test(s)); private void Test(string s) { throw new NotImplementedException(); }

How to open a new window using MVVM Light Toolkit

Passing a message from ViewModel1 to View1 means to use the messaging capabilities in the MVVM Light Toolkit. For example, your ViewModel1 could have a command called ShowView2Command, then it would send a message to display the view. public class ViewModel1 : ViewModelBase { public RelayCommand ShowView2Command { private set; get; } public ViewModel1() : … Read more

tech