Archive for the ‘WPF’ Category

Useful WPF Data Converters

May 31st, 2012 No comments

Just sharing the most common WPF data binding converters that I encounter on day to day basis. This should be beneficial for every WPF developer.


Usage in XAML should be as follows:

  1. Define the XAML namespace to point to the common namespace where you would store your common converters. For example:
  2. <window ...
           xmlns:converters="clr-namespace:MyCompany.MyProject.MyConverters" >
  3. Use converter like this:
  4. <button Content="Push Me" Click="ButtonConvertToBool_Click"
           Visibility="{Binding Path=Something, Converter={x:Static converters:BoolToVisibleConverter.Instance}}"
           IsEnabled="{Binding Path=SomeOtherThing, Converter={x:Static converters:IsNotNullConverter.Instance}}"></button>

Common Converters


Gets an object as an input and returns true if the object is not null; otherwise returns false.

public class IsNullConverter : IValueConverter
    private static readonly IsNullConverter _instance = new IsNullConverter();

    public static IsNullConverter Instance
        get { return IsNullConverter._instance; }

    private IsNullConverter()

    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            return (value == null);
            return null;

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        return Binding.DoNothing;

Read more…

Some Useful Code Snippets for C#/WPF

September 14th, 2010 No comments

Attached are some code snippets that I use during code development.

  • newClass – code Snippet for creating a class
  • newClassNotify – code Snippet for creating a class which implements INotifyPropertyChanged interface
  • dprop – code snippet for a property using DependencyProperty
  • dpropu – code snippet for a property using DependencyProperty with ChangeCallback notifier
  • dpropObCollection – code snippet for a property using DependencyProperty to an ObservableCollection
  • conv – code Snippet for creating a IValueConverter
  • multiconv – code Snippet for creating a IMultiValueConverter
  • propNotify – code Snippet for creating a property with get/set accessors and property value change notification trigger

Attached Files:

Cool Stuff in WPF

July 27th, 2010 No comments

Model-View-ViewModel (MVVM)

July 26th, 2010 No comments

This is another post where I will gather useful documentation about so called Model-View-ViewModel pattern used for GUI development in WPF environment.

Identifying and Eliminating C#/WPF Memory Leaks

June 30th, 2010 No comments

PhotoSuck Beta is now released!

October 21st, 2009 2 comments

Hi everybody. At last long-awaited “PhotoSuck Beta” is on air. Its still in testing stage and You’re welcome to be one of its first users. For those guys who are new to “PhotoSuck” – its a windows based application which downloads Your desired photos from Flickr and Picasa. Your desires are defined by sets of criterias. Criterias include social relevance(specific users’ photos, Your friends’ photos, …); tag relevance; picture quality (portrait, landscape, HD, SD, …); upload date; and more. All this is achieved using cute WPF application, which looks like this:

PhotoSuck Beta Main Screen

Read more…

Attached Files:

WPF Animatable Button

April 10th, 2009 2 comments


This article is about simplifying the process of defining animation for button mouse over, pressed, enabled and disabled animations. The process of defining triggers is quite complicated when you include all IsMouseOver, IsPressed and IsEnabled states. You will also need to work hard and define BeginStoryboard/StopStoryboard precisely to make your desired animation start. Some of these states are overlapping. For instance when the button is in IsPressed state, most likely it will be also in IsMouseOver state and what leads to improper animation to act. It is also quite annoying to define all these complex triggers every time for such a common problem.
Read more…

Attached Files:

WPF Maskable TextBox for Numeric Values

March 10th, 2009 39 comments


This article describes how to enhance WPF TextBox and make it accept numeric(integer and floating point) values. The second goal is make the TextBox smart enough to have it easier to input numerics. The easy means to provide the TextBox with some kind of intelligence not just rejecting non-numeric symbols. Provided extension also allows setting minimum and/or maximum values.
Read more…

Attached Files: