September 2010

during the last weekend SQL Server Management Studio Setup drove me crazy prompting up the following error few seconds after launched it on Windows 7.
TITLE: SQL Server Setup failure.
SQL Server Setup has encountered the following error:
Invoke or BeginInvoke cannot be called on a control until the window handle has been created..
TITLE: SQL Server Setup failure.------------------------------
SQL Server Setup has encountered the following error:
Invoke or BeginInvoke cannot be called on a control until the window handle has been created..

The solution of the problem is easy if you know it ūüėČ

Solution: launch the setup and when the error message box appears, just copy the temporary folder C:\{GUID} into your desktop and then close the error message box. Launch again the setup from your desktop directory you just copied and magically the setup does not prompt again any error message!

In order to easily complete SQL Server Management Studio 2008 installation I suggest you to read the following article which describes the steps:



Hi all,
if you come here you were problably looking for a control like the following (download source code):
The control also allow to show Column Headers. For displaying them you just need to modify the Height=“O” in XAML code.

The example combines two ideas I found into two articles:

The below class diagram shows the classes used for data binding purposed and representing displayed data:


Hi guys,
what I would like to share with you today is how to display data in hierarchical view in WPF via the powerful mechanism of databinding! The source code is downloadable here as well as the Artists.xml file.
The below pictures displays an XML file and the relevant representation in a WPF TreeView.


The code for building an Hierarchical TreeView using WPF HierarchicalDataTemplate is copy-paste below:


            <!-- Data Binding to Artists.xml -->
            <XmlDataProvider x:Key="myArtistsData" Source="DataSources/Artists.xml" XPath="/Artists" />

            <!--Template for "Song" -->
            <HierarchicalDataTemplate x:Key="song_hdt">
                <TextBlock Text="{Binding XPath=@Name}" />

            <!-- Template for "Album" -->
            <HierarchicalDataTemplate x:Key="album_hdt"
                                      ItemTemplate="{StaticResource song_hdt}"
                                      ItemsSource="{Binding XPath=Songs/Song}">
                <TextBlock Text="{Binding XPath=@Name}" />

            <!-- Template for "Artist" -->
            <HierarchicalDataTemplate x:Key="artist_hdt"
                                      ItemTemplate="{StaticResource album_hdt}"
                                      ItemsSource="{Binding XPath=Albums/Album}">
                <TextBlock Text="{Binding XPath=@Name}" />


        <TreeView ItemsSource="{Binding Source={StaticResource myArtistsData}, XPath=Artist}"
                  ItemTemplate="{StaticResource artist_hdt}"/>


The XmlDataProvider is used as item source for the TreeView via binding. The TreeView specifies as ItemTemplate the artist_hdt which is a HierarchicalDataTemplate that is used in the following way:

  • Everything you put inside HierarchicalDataTemplate tag is used for displaying the current item
  • ItemsSource defines which data shall be displayed as child of current item
  • ItemTemplate defines the way to be used to display child data

Hope to be helpful ūüôā

Today I want to share with you a very nice way for customizing text wrapping on TextBlock in WPF.
Sometimes happens that displayed string are too long to be displayed entirely in a single cell and you need to split the string in multiple lines. WPF is able to automatically split long string in multiple lines via TextWrapping property. However it can happens that the line breaking algorithm used by WPF does not satisfy your requirements, especially when you need to split your application specific strings like mathematical formulas or hierarchy paths.

Lets assumes we would like to display a string in a multi line way like the following pictures:

In order to achieve these results we need to set the TextBlock in the following way:

<TextBlock Width="28"  TextWrapping="Wrap" TextTrimming="CharacterEllipse"  Text="{Binding Location}"/>
  • The TextWrapping=”Wrap” will split the displayed string in multi-lines (like the second and third pictures) using the standard unicode line breaking algorithm.
  • The TextTrimming=”CharacterEllipse” is used for¬†trimming¬†text and¬†continuing¬†with an ellipsis at the character closest to the trimming edge (as shown in last pictures).

The Text=”{Binding Location}” is used for displaying the content of Location Dependency Property that is initialized by code behind in the following way:

Location = "Building 1.Floor 1.Room 4";
Location = Location.Replace(" ", "\u00a0").Replace(".", ".\u200B");

and here explain the tricky used for customizing line breaking algorithm:

  • The first Replace() replaces the standard Space¬†character¬†with he Unicode Non-breaking space (U+00A0) with the side effect to deny the line breaking algorithm to break the string
  • The second Replace() puts the Unicode Zero Width Space (U+200B) after dots with the side effect to¬†allowing¬†the line breaking¬†algorithm to break the string