Apr
23rd | 2008

WPF DataTemplate for Interfaces? Not Supported

Posted by Shahar Y |
Filed under .Net, WPF |

DataTemplates are a great feature introduced in WPF, it allows to determine how data is presented and how data binding accesses the presented data. Just as we can apply a visual style to a specific UI control, we can do it for a specific data type. There is just one problem here, DataTemplates are good [...]


Continue Reading...
Apr
21st | 2008

A Bug in WPF Static Resources?

Posted by Amit |
Filed under C#, WPF |

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...
Apr
15th | 2008

How to Create a Word Like Font Selection in WPF ComboBox

Posted by Amit |
Filed under C#, WPF |

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...
Apr
3rd | 2008

Is WPF Data Binding thread safe?

Posted by Shahar A |
Filed under WPF |

We wanted to check whether WPF data binding is thread safe, and made a little test (using .NET 3.5). Lets look at the Worker class, which has one property - Money, and is making money in a multithreaded way :) - creating 100 threads and increasing the “Money” property from each one of them:
class Worker : INotifyPropertyChanged [...]


Continue Reading...
Mar
25th | 2008

Customize SpellCheck on WPF Text Controls

Posted by Shahar Y |
Filed under WPF |

WPF has a great feature for spell checking called SpellCheck, which is applied on TextBox and RichTextBox controls. In this post I will explain about it and how can it be customized. Lets go back to the start, to activate the spell checker just set SpellCheck.IsEnabled property to True. Easy, right?. Take a look at [...]


Continue Reading...
Mar
24th | 2008

Using WinForms with WPF, Watch Out!

Posted by Amit |
Filed under C#, WPF |

Here is an interesting thing that happened to me at work.
For various reasons the application i am working on has a Windows Form in its base, and most of the controls are WPF, part of them are WinForms. The weirdest thing happened to me as i was trying to open a WPF Window from one [...]


Continue Reading...
Mar
10th | 2008

How to Sort Elements in a Content Control Without Touching The Data.

Posted by Amit |
Filed under C#, WPF |

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...
Mar
7th | 2008

Binding a WPF Control To a Dictionary

Posted by Amit |
Filed under .Net, C#, WPF |

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...
Jan
14th | 2008

How to Solve error CS0103: The name ‘InitializeComponent’ does not exist in the current context

Posted by Amit |
Filed under C#, Visual Studio, WPF |

Hi.
Ever had the following error in Visual Studio:error CS0103: The name ‘InitializeComponent’ does not exist in the current context.I sure did…
There’s a very specific reason for this and it’s in the project settingsThis usually happens whenever you try to add a WPF control/window to a .NET 2.0 Class library or project. The reason for this [...]


Continue Reading...
Jan
5th | 2008

How to Use Hierarchical DataTemplates - Improved !!!

Posted by Amit |
Filed under .Net, C#, Visual Studio, WPF |

Hi all.
First of all Let me give credit to Shahar A. for showing me this.
As it turns out, my latest post about DataTemplates was not the most efficient way to do this.
I used a different Template for the root and a second one for the all the rest of the data.
What i learned is that [...]


Continue Reading...

Search Dev102