Archive for the ‘Best Practices’ 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:

Installing Team Foundation Server (TFS) 2010

August 1st, 2010 1 comment

Steps to install TFS 2010.

  1. Install Windows Server 2003 SP2.
  2. Install SQL Server 2008 R2. Do not configure Reporting Services at this step!
  3. Install WSS 3.0 SP2. See details
  4. Configure Reporting Services.
    • Choose native mode if you do not require to use Microsoft Sharepoint Portal
    • Choose Sharepoint integrated mode only if really required
  5. Install TFS 2010.
  6. Do not forget to install Team Foundation Extension for Sharepoint Services even if you are setting up a a singe server configuration.
  7. Configure TFS 2010 using the wizard in TFS Administration Console.
  8. Replace local server name with FQDN to expose public access to the server. Follow this post to rename URLs. After that go to Sharepoint Extension configuration in TFS Administration Console and replace URL with FQDN.

Some problems you might encounter during/after installation of TFS 2010

  • Problem:When running TFS 2010 upgrade wizard and reaching Readiness Checks you might get an on ‘Configuration Database’ step. The message can say: “TF255440: The following account has a SQL Server login, but the login was denied access: DOMAIN\User. The server selected to host the databases for Team Foundation Server is: MYSERVER. The SQL Server login associated with the user account must be granted access to the SQL Server instance on that server.”


    Delete that DOMAIN\User account from SQL Logins. You should not get that message again.

  • Problem:When connecting SharePoint to TFS in Team Foundation Administration Console you most probably will get “TF255329: The following site could not be accessed … ” error when clicking “Validate Path” button.Solution:

    Even though you have a single server setup you need to install TFS Extension for SharePoint. Once installed you will able to easily connect Sharepoint to TFS.

Useful links related to TFS 2010 Installation

Compromise in code

July 27th, 2010 No comments

Today I encountered another wild animal while surfing in the jungle. Pretty much nothing to comment 🙂

if (visiblePath == null)
     visiblePath = new DispatcherTimer();
     visiblePath.Tick -= new EventHandler(visiblePath_Tick);
     visiblePath.Tick += new EventHandler(visiblePath_Tick);
     visiblePath.Interval = TimeSpan.FromSeconds(500);
     visiblePath.Tick -= new EventHandler(visiblePath_Tick);
     visiblePath.Tick += new EventHandler(visiblePath_Tick);

Code Duplication

September 24th, 2009 No comments

Today at the office I encountered another nightmare. It seems like the author of the code above was doing the development late at night, he sleep in the middle and unintentionally pushed Ctrl-V button.

Read more…

Scope Nightmare

September 9th, 2009 2 comments

Today at the workplace I came across a very weird chunk of code. An enormous block of code was wrapped in 25-30 levels of brackets. On a a standard resolution screen (1280×1024) the code was completely out of screen. After spending some time on refactoring it and eliminating annoying scopes I decided to take a screenshot and post it here.

Below I will describe reasons that can lead to such kind of issues and possible solutions.
Read more…

Attached Files:

C# Coding Standard, Naming Conventions and Practices

March 1st, 2009 5 comments

Here I describe coding style and conventions you would encounter when going over my source codes. Most of them are easy to follow and understand. Read more…