Displaying user Messages, Errors and Dialogs from a ViewModel using a Service – Part 2

Tuesday, December 18, 2012

Displaying user Messages, Errors and Dialogs from a ViewModel using a Service – Part 1In my previous post, I've discussed a bit about using the MVVM pattern and how to display a message or opening a dialog from within the view-model. As part of the discussion, I've shown a possible way for displaying Messages, Errors and even Dialog or Popups. In this post I would like to provide more details about the implementation of the Dialog part.  Recall previous post, we have the following two methods of the user interaction service:  bool? ShowDialog<TConductor>(string title) where TConductor : IDialogConductor;  bool? ShowDialog<TConductor, TParameters>(string title, TParameters parameters) where...
no comments

Displaying user Messages, Errors and Dialogs from a ViewModel using a Service – Part 1

Monday, December 17, 2012

Displaying user Messages, Errors and Dialogs from a ViewModel using a Service – Part 2 Years after the invention of the MVVM pattern and people are still asking many questions about how to do this and how to do that, and specifically, how to display a Message, Error or even opening a Dialog from a View Model without accessing the view layer or visual tree. If we go straight with the MVVM pattern concept, the view-model must not directly access or manipulate the View/Visual Tree or part of it in any circumstances. As many of you may already familiar...

Open Window, Dialog or Message Box from a ViewModel – part 2

Friday, April 1, 2011

In my previous post I have shown how to open a Window bound to a view-model triggered by the view, using a simple Action. In this post I'll show how to open a Window, triggered by the view-model.   Opening a window directly by the view where the view decides when a Window should be opened, is an incorrect approach since the view shouldn't make that decision. This decision belongs to the Application layer and not the Presentation layer. What if the view shouldn't be opened because of application state, user permissions or any other application...
one comment

Open Window, Dialog or Message Box from a ViewModel – part 1

Friday, March 25, 2011

Saying that a view-model belongs to the Application layer, and the Application layer doesn't references upper layers, and must not create or use visual objects, how can I open a Window, Dialog or any kind of Message Box on-the-fly, based on some logic triggered by the view or view-model? Well, there are several options doing that, one is using kind of service which encapsulates that, providing an interface, so the view-model don't really work directly with the upper layer or WPF. This solution is somehow problematic since the service should be implemented in the Presentation layer and...

Blendability Part IV – Design Time Support for MEF

Wednesday, February 9, 2011

In my previous post I've discussed the usage of MEF with the famous MVVM pattern, and demonstrated the usage of my Import markup-extension, and how it can replace the View Model Locator with an elegant syntax. In this post I would like to reveal and discuss the implementation of the Import markup-extension. Let's begin with a short story. Say that you're building an application for controlling a robot. The robot lives happily in a 2D surface, and can be move freely in between the surface's walls. To visualize both the robot and the surface parts you've created two parts: A Robot...

Blendability Part III – View Model Locator Replacement using MEF

Wednesday, January 19, 2011

Everybody loves MEF! Don't you? I think MEF is one of the best things happened to the latest .NET Framework 4. Just in case that you don't know what I'm talking about, I urge you to start reading about MEF in my colleague, Bnaya Eshet, blog. He has great MEF tutorial for beginners. So why am I writing about MEF in this WPF related post anyway? Well MEF is a great framework for extensibility and object composition, also it can be used as a DI container, declaratively and imperatively. With my experience in architecting several WPF...

Blendability Part II – Design time support for Prism

Monday, January 3, 2011

In my previous post I’ve presented the Blendability concept and explained how to leverage Blend’s sample-data generation in order to support view-model at design time. In this post I would like to continue with this concept and reveal a tiny research I’ve done related to design time support of Prism modules. If you’ve ever developed a WPF Composite Application using Prism you may be aware of a frustrating problem while trying to work with the Shell at design time. It always ends with something like this: As you can see, the Shell is always left blank, and there is no way to...

Blendability Part I – Design time ViewModel

Friday, December 17, 2010

In case that you haven't added the word ‘Blendability' to your XAML Jargon yet, I’m sure this post will inspire you doing so. The Blend-ability term describes how a piece of data model or view model is viewable or designable at design time, whether by Expression Blend or Visual Studio Designer. Building a Silverlight or WPF applications, everybody loves using the MVVM pattern. This pattern greatly decouples the view from its logic and domain model, hence enabling relatively easy unit testing and provide great flexibility. In most cases there should be no code behind XAML except for...

WPF Data Validation using .NET Data Annotations – Part I

Tuesday, October 26, 2010

Introduction There is a beautiful declarative mechanism in the .NET framework called Data Annotations designed for use with ASP.NET Dynamic Data controls. “The System.ComponentModel.DataAnnotations namespace provides attribute classes that are used to define metadata for ASP.NET Dynamic Data controls” . Thanks to the .NET Framework 4.0 Validator class we can leverage this mechanism in our own applications, no matter if using ASP.NET at all. This time I’ll show how to use attribute based data validation on our models or view-models. Next time I’ll show how to extend my NotifyingObject class to support this...
tags: , , ,
no comments

NotifyingObject for WPF & Silverlight

Monday, October 11, 2010

There are many ways notifying on property changed, and I think the most popular one is using the lambda expression solution: public class Ball : Model { private double _velocity; public double Velocity { get { return _velocity; } set { if (_velocity != value) ...