Making NotifyPropertyChanged refactorable.

Common problem when using INotifyPropertyChanged interface is that the PropertyChangedEventHandler event accept a string property name as a parameter. That cause a possible problem when we want to refactor the property and forget to update the provided property’s name. There is a plenty of blog threads in the web that tries to solve this problem. The very common solution benefi…

By Mirek on (tags: INotifyPropertyChanged, categories: code)

Sortable and expandable enums

Have you ever faced the problem that extending enum type by new values may cause unpredicted behavior of the application? I recently have. As the solution for this problem I figure out how to design enum values so they can be easily sortable and easily expandable in future, causing no side effect. We have a simple enum type ConstructionSteps we use   The framework will aut…

By Mirek on (tags: enums, categories: code)

WPF switch panel

The panel which switch its content depending on the value of boolean flag is the topic of this post. The WPF application I’ve recently coded was a MvvM application and had a number of editable fields. The fields were editable only in specific circumstances and when the proper flag IsEditionMode has been set to true on the ViewModel. For trivial cases I could use TextBox with Is…

By Mirek on (tags: custom controls, SwithPanel, WPF, categories: code)

MVC parameter binding

Here’s a piece of information that will hopefully save you the time I spent on trying to figure it out… asp.net mvc parameter binding is localizable ONLY in the case of POST form action. So if you’re trying to bind a date time, and have globalization turned on in web.config, then you need to parse the parameter yourself. The parameter needs to be of type string, because making …

By on (tags: mvc, categories: code)

Event aggregation

In this post I will try to present you my implementation of event aggregator, which I used in WPF MvvM application. I will also try to point out the advantages of my implementation over other found in the internet. The basic principle of event aggregator is to decouple objects from themselves, but at the same time make them still able to communicate to each other. The idea behi…

By Mirek on (tags: event aggregator, 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)

Configuring simple TraceSource for logging purposes

In the previous post we saw how to use the built in Trace class for logging facilities. However the Trace class is not the latest Microsoft’s recommended way for logging your application. In this post I will try to present the quickest way of configuring TraceSource and use it for logging purposes. TraceSource class allows you to create as many trace sources as you want and fre…

By Mirek on (tags: c#, logging, .net, TraceSource, tracing, categories: code)

Simple logging with use of System.Diagnostic.Trace

Recently we have decided to replace the logging framework we used, because of its not necessary complexity and a bunch of features we did not use and even did not know anything about. The goal was to use the built in System.Diagnostic.Trace facility and cover some of basic requirements we had. Basically, all we need the logging thing should do is to properly log error with all …

By Mirek on (tags: logging, Trace, tracing, categories: code)

CSS Preprocessors – Sass, Less, Stylus

CSS has been around for a while and will stay for a while longer and although I think it’s a good and working ‘language’ it has a few pitfalls – the biggest one being the lack of ability to reuse certain parts. Take colors for example, when you want to style a site you need to repeat the color declaration everywhere you want to set it, so when you change your mind, the only way…

By on (tags: css, less, sass, stylus, categories: code, web)

Simple, bindable PieChart in WPF

Today I will show you a simple way to have a pie chart in your WPF application with use of ItemsControl. The pieces of the pie will be binded to the undergoing item model collection. Let’s take a look at it. The goal is to achieve a pie chart presented on the picture below, having just a collection of items.     Each item should be an object with following properties …

By Mirek on (tags: itemscontrol, Pie Chart, WPF, categories: code)