Hi all
As you all remember in my article about Custom WPF Context Menu I mentioned that my WPF Binding Converter was a singleton, and I promised to tell you why, so here comes the 3 ways I know of using WPF Binding Converters. We will start from the worst (in my opinion) and move on the the best.
To start off here is the Binding Converter:
Continue Reading...
How would you like your WPF application to have a Context Menu like this:

Well, It is not so hard. Here is how you do it:
Continue Reading...
Every one of us, software developers, experienced situations where the .Net Framework could not locate an assembly and ended up facing the TypeLoadException. These failures usually happen due to an assembly deployed to the wrong location or a mismatch in version numbers or cultures. A quick way to check what went wrong is to open the module window (Visual Studio) during debugging but that may be sometimes impossible or inconvenient because:
-
We may not have Visual Studio installed.
-
We installed the product in the customer site and we don’t have the code available.
-
It is some third party assemblies which causes the problems.
Luckily, there is an assembly binding log viewer which displays information that helps us diagnose why the .NET Framework can not locate an assembly at run time. This tool is called
Continue Reading...
We have all used WPF DataTemplates, but I bet most of you never gave thought to the meaning of the x:Key attribute. We all know the meaning of the DataType attribute, which determines to what type of data the template will apply to. But what about the x:Key why is it there? Lets tale a look at the following code:
<Window.Resources>
<DataTemplate DataType=”{x:Type data:s}”>
<Button Width=”50″ Height=”50″>
<TextBlock Text=”{Binding text}”></TextBlock>
</Button>
</DataTemplate>
</Window.Resources>
<Canvas>
<ItemsControl ItemsSource=”{Binding}”>
</ItemsControl>
</Canvas>
Continue Reading...
Master-Detail is a pattern for displaying details of a specific item selected from a list of items. In this post I’ll demonstrate how to use master-detail in WPF with two levels of objects, each displayed in a ComboBox and Data Binding to tie them together.
Continue Reading...
Yesterday I played around with WPF resources and stumbled on a very strange behavior. It seems that the order of the elements in the resources have some importance as to how the application handles them. A few code examples are attached
Continue Reading...
If you are writing an application that uses font you will find this post very useful. Making a font selecting ComboBox that shows a preview of the fonts in WPF is very easy, here is how to do it:
First we will have to create the ComboBox Code, this is a regular ComboBox we have all [...]
Continue Reading...
Often we want to display a list of elements and allow the user to sort them in various ways. There are many ways to do it and I wanted to show you how to use a SortDescription Object. What is a SortDescription object you ask? It receives two parameters in its constructor: the first is [...]
Continue Reading...
Binding to a dictionary can be tricky.
It sounds simple but it never works on the first try. Usually when you first run you application you see that instead of the beautiful template you created for the items, you get something that looks like a pair of key and value. your binding works fine, you just [...]
Continue Reading...