What is Prism for WPF?

Prism is the Microsoft Patterns and Practices Team official guidance for building “composite applications” in WPF and Silverlight. It’s intended to provide guidance on the best practices for building large scale applications which are flexible in terms of development and maintainability. This includes guidance on dependency injection (via Unity or MEF), layout (including using MVVM), … Read more

Good examples of MVVM Template

Unfortunately there is no one great MVVM example app that does everything, and there are a lot of different approaches to doing things. First, you might want to get familiar with one of the app frameworks out there (Prism is a decent choice), because they provide you with convenient tools like dependency injection, commanding, event … Read more

Good or bad practice for Dialogs in wpf with MVVM?

This is a good approach and I used similar ones in the past. Go for it! One minor thing I’d definitely do is make the event receive a boolean for when you need to set “false” in the DialogResult. event EventHandler<RequestCloseEventArgs> RequestCloseDialog; and the EventArgs class: public class RequestCloseEventArgs : EventArgs { public RequestCloseEventArgs(bool dialogResult) … Read more

Handling the window closing event with WPF / MVVM Light Toolkit

I would simply associate the handler in the View constructor: MyWindow() { // Set up ViewModel, assign to DataContext etc. Closing += viewModel.OnWindowClosing; } Then add the handler to the ViewModel: using System.ComponentModel; public void OnWindowClosing(object sender, CancelEventArgs e) { // Handle closing logic, set e.Cancel as needed } In this case, you gain exactly … Read more

Android ViewModel additional arguments

You need to have a factory class for your ViewModel. public class MyViewModelFactory implements ViewModelProvider.Factory { private Application mApplication; private String mParam; public MyViewModelFactory(Application application, String param) { mApplication = application; mParam = param; } @Override public <T extends ViewModel> T create(Class<T> modelClass) { return (T) new MyViewModel(mApplication, mParam); } } And when instantiating the … Read more

In MVVM should the ViewModel or Model implement INotifyPropertyChanged?

I strongly disagree with the concept that the Model should not implement the INotifyPropertyChanged. This interface is not UI specific! It simply informs of a change. Indeed, WPF heavily uses this to identify changes, but that doesn’t mean it is an UI interface. I would compare it to the following comment: “A tire is a … Read more

This type of CollectionView does not support changes to its SourceCollection from a thread different from the Dispatcher thread [duplicate]

Since your ObservableCollection is created on UI thread, you can only modify it from UI thread and not from other threads. This is termed as thread affinity. If you ever need to update objects created on UI thread from different thread, simply put the delegate on UI Dispatcher and that will do work for you … Read more

Add directives from directive in AngularJS

In cases where you have multiple directives on a single DOM element and where the order in which they’re applied matters, you can use the priority property to order their application. Higher numbers run first. The default priority is 0 if you don’t specify one. EDIT: after the discussion, here’s the complete working solution. The … Read more

tech