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)

Customizing WPF combo box style

It this post we will try to create a custom combo box style which adjust the look of standard control to our needs. In general we will try to change this standard look of combobox and achieve something like this Great styling examples for combo box, buttons and tab items can be found on Codeplex, which I based my work on. If you are not familiar with styling in wpf there is a l…

By Mirek on (tags: combobox, CustomTemplate, style, WPF, categories: code)

Simple WCF. Hosting WCF service by Autofac in ASP.NET MVC 3

One of features of Autofac is that it can be used to host a WCF service. I have tried to host a WCF service within an already existing ASP.NET MVC 3 web application. The problem was that the service needed to use some resources which were managed by Autofac and was also used this MVC application. I spend few hours until I figure out what is going on and how to make it work toge…

By Mirek on (tags: Autofac, IoC, MVC 3, WCF, 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)

Finding gaps in a sequence of identifier values of sql table.

Today I would like to present a couple of solutions for problem of finding gap in a sequence. This issue will be considered in context of finding missing – gap identifiers in the database table. All examples of code are T-SQL scripts and statements and were tested on SQL Server 2008 Express 1. Integer typed identifiers Lets assume we have an sql table with following schema Fiel…

By Mirek on (tags: gaps in sequence, id gap, table id finding, categories: code)

MVC Greedy route mapping and custom route handler

I’m learning to love MVC mostly for it’s flexibility. In a recent situation, I wanted to have a generic controller that will perform CRUD (Create Read Update Delete) operations on an entity. By default, this is not handled, but with a little custom code, it turned out to be quite easy. Let me describe the use case first. The idea is to have a controller (let’s call it Foo) that…

By on (tags: mvc, categories: code)

Simple WCF. RESTful and SOAP endpoint at one contract.

REST (Representational state transfer) web service is a service over HTTP with specific architecture. The REST is then an architectural style, which defines the rules of accessing resources exposed in the web. In principle the restful service exposes some sort of resource, for instance collection of entities, which can be easily accessed and changed from external client. To be …

By Mirek on (tags: REST, SOAP, WCF, web service, categories: code)

Simple WCF. The simplest configuration.

The power of WCF is that it can be used to any kind of communication. All known old transmission protocols are covered by WCF and can be totally replaced by it.   Unfortunately the drawback of this flexibility is complicated configuration in case when we want to do something not standard. In WCF 4.0 this has been a little simplified, so now when you want to do simple thing…

By Mirek on (tags: WCF, categories: code, web)