Plugins in WPF MvvM with MEF

In this post I will show you the way we can implement a plugin functionality in WPF MvvM application with use of Managed Extensibility Framework (MEF). MEF is a tool that may facilitates extending and decoupling your application. In some scenarios it is very similar to Dependency Injection, but is rather focused on one primary purpose: Import and Export of objects. What is good…

By Mirek on (tags: MEF, mvvm, Plugins, WPF, categories: architecture, code)

Cross-property validation in WPF MvvM

In a previous post I have described hot to utilize a INotifyDataErrorInfo interface. Today I will show you my solution for automated cross-property validation integrated with the ModelValidation base class from previous post. First I add a custom CrossValidationAttribute and later on a virtual method which will be called from above CrossValidationAttribute for each property mar…

By Mirek on (tags: CustomValidationAttribute, mvvm, validation, WPF, categories: code)

Utilizing INotifyDataErrorInfo in WPF MvvM app

Today I will show you how I utilize the INotifyDataErrorInfo interface to accomplish validation mechanisms in WPF application.   A time ago I have described how to validate model in WPF application with use of IDataErrorInfo interface. Now in WPF 4.5 we have another possibility which is the INotifyDataErrorInfo interface. The MSDN documentation is here a little scarce, but…

By Mirek on (tags: INotifyDataErrorInfo, mvvm, validation, WPF, categories: code)

Automatic ICommand activation in WPF

Today I will present you my solution for automatic command activation in WPF MvvM application. Standard command implementation that can be binded in XAML looks similar to this then you have to create the instance of the command and assign it. I usually use the DelegateCommand which is a ICommand implementation with Actions inside. Now since the first part is necessary, because …

By Mirek on (tags: comanding, DelegateCommand, mvvm, WPF, categories: code)

Simple validation in WPF MvvM Part 2

In a previous post I showed you how to use IDataErrorInfo interface to implement simple validation mechanism in WPF MvvM application. In this post we will try to extend and customize this approach a little. It would be nice I the fields of the form be validated on Save button click. So the user will not see error messages when he opens the for for the first time To achieve that…

By Mirek on (tags: IDataErrorInfo, mvvm, validation, WPF, categories: code)

Simple validation in WPF MvvM using IDataErrorInfo

In this post I will try to demonstrate the simplest validation approach for Windows Presentation Foundation application designed in Model View View-Model pattern. We will be using data binding and IDataErrorInfo implementation. Ok. Let’s assume we have simple data model ProductModel which looks like this So we have Name, Price and Amount text boxes, which we want to bind to the…

By Mirek on (tags: IDataErrorInfo, mvvm, validation, WPF, categories: code)

WPF MvvM - simple approach

Model View View-Model is one of most popular design pattern used in WPF applications. Thanks to binding, dependency properties and other features, WPF has been adjusted and, I believe,  somehow designed to be used with MvvM pattern easily. There are many MvvM frameworks for WPF which support creating loosely coupled and scalable wpf applications. We can use Prism, Cinch, M…

By Mirek on (tags: mvvm, WPF, categories: code)

Localized enums with Entity Framework Code-First 4.1 in WPF MVVM and ASP.NET MVC 3. Part 3)

Part 3. Displaying and binding localized names of enum values in ASP.NET MVC 3 application To display localized enums in ASP.NET MVC 3 application we use custom description attribute described in Part 2) and extension method to get the description for each enum value. The type converter is not useful here so we need another approach to achieve the goal. Let’s generate the editi…

By Mirek on (tags: ASP.NET MVC, Code First, Entity Framework, enums, lozalization, mvvm, WPF, categories: code)

Localized enums with Entity Framework Code-First 4.1 in WPF MVVM and ASP.NET MVC 3. Part 2)

  Part 2. Displaying localized names of enum values in WPF application To achieve the human readable enums I have performed following steps. For each language I want to support I have added a resource (.resx) file with key equals the string representation of the enum value.   Then we decorate our enum values with Display attribute as follows As a description we can pr…

By Mirek on (tags: ASP.NET MVC, Code First, Entity Framework, enums, localization, mvvm, WPF, categories: code)

Localized enums with Entity Framework Code-First 4.1 in WPF MVVM and ASP.NET MVC 3

In part 1) I would like to present the solution of using enum types with Entity Framework Code-First (EF CF later). Then in part 2) I would like to show how easily display these enums in WPF MVVM and in Part 3)  I will try to explain my approach for displaying and binding localized enums in ASP.NET MVC 3 application. EF CF approach is still developed and in version 4.1 it …

By Mirek on (tags: ASP.NET MVC, Code First, Entity Framework, enums, localization, mvvm, WPF, categories: code, web)