DCSIMG
Pattern - Essential WPF

Browse by Tags

All Tags » Pattern (RSS)

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

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...
תגים:, , , , ,

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

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...
תגים:, , , , ,

Blendability Part IV – Design Time Support for MEF by Tomer Shamam

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...

Blendability Part III – View Model Locator Replacement using MEF by Tomer Shamam

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...

Blendability Part II – Design time support for Prism by Tomer Shamam

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...

Blendability Part I – Design time ViewModel by Tomer Shamam

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...

WPF Data Validation using .NET Data Annotations – Part I by Tomer Shamam

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” [MSDN]. 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...
תגים:, , ,

NotifyingObject for WPF & Silverlight by Tomer Shamam

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 ) { _velocity = value ; NotifyPropertyChanged(() => Velocity); } } } } I’ve to say that using the lambda solution is cool and type safety. But, why should I bother creating a field member for each property, set it only if not equals to the...

Session – Advanced Topics for Building Large-Scale Applications with Microsoft Silverlight by Tomer Shamam

In this session, John Papa talked about Silverlight application development patterns such as composite applications with Prism, developing using the Model-View-ViewModel (MVVM) pattern, and methods of implementing large, modular, multi-page applications within your team. Also he talked about frameworks created to help assist in rapid development using these patterns without sacrificing good application development patterns. MVVM is a pattern, there is no specific way to do it right. Also with Silverlight...

WPF + MEF = Declarative Composite UI by Tomer Shamam

I’ve been playing around with MEF lately and I have to say that it has a great potential for building Composite UIs. One of the sample applications arrived with MEF Preview 6 (called MEFLook) , demonstrates how to implement kind of Outlook composite application based on WPF. The interesting part of this application is that views can be imported into the main window as dynamic parts, simply by decorating them with the MEF Export attribute. < Window x : Class ="MeflookSample.MeflookShell"...

WPF Commands Everywhere by Tomer Shamam

It has been a long time since I’ve written something in my blog and there are many items in my stack. Unfortunately, I don’t have the time to pop all, so I’ll try to peek few of my best thoughts. In the last few weeks I’ve started to work on a very interesting UI infrastructure project, based on WPF and Prism. I can’t give many details since it’s kind of confidential, but I can say that I work with very talented people, and Lior Rozner from Microsoft Israel is one of them. So enough about what I...
תגים:, , ,

Composite Application Guidance for WPF (Prism) Tour - Part 2 by Tomer Shamam

In the first post of this series I generally wrote about Prism and how can it fit in WPF applications. In this second post I would like to introduce a Home Automation application UI, show how to design it as a monolithic application, talk about the disadvantages of a monolithic application, and finally show how to design it as a Composite Application. What is a Home Automation? "For some it may be something as simple as remote or automatic control of a few lights. For others, security may be...
תגים:, , , ,

Composite Application Guidance for WPF (Prism) Tour - Part 1 by Tomer Shamam

If I would be asked, “What are the best two things happened to Smart Client and Desktop Applications developers in the last two years” I certainly would say “Microsoft's WPF and Prism infrastructures”. WPF is the aircraft’s Engines, and Prism is the HAL and this makes us proud to be an aircraft pilots. But it’s not enough to just sitting in the cockpit, wearing a pilot suit. We should know how to control both. With this post I want to start a series of posts regards Composite Application Guidance...
תגים:, , , ,

Data Binding for Pure CLR Objects by Tomer Shamam

WPF has a great support for handling data: Data Binding. Unfortunately, one of the elements you bind to (the target) must have a DependencyProperty (known as the target-property). What if you don't have a dependency property to bind to, or you just want to bind two CLR types? For example let say that you wrote an application for simulating a car. You may have a Car and a Speedometer classes. Let say that a car handles its own speed, hence the car has its own speed state exposed by a Speed property...

WPF Model Data Binding - Part II by Tomer Shamam

In my previous post I showed how to design a data model which provides the following characteristics: Property notification changes In-memory state persistency Commit and Rollback mechanism Dirty flag In this post I will show how to handle multi-threading scenarios with WPF data binding. You can download the complete code from here . Before I will start, I want to give a little background of the WPF threading model, and to explain why you shouldn't change any data-bind object from a different thread...
תגים:, , ,
More Posts Next page »
Powered by Community Server (Commercial Edition), by Telligent Systems