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...
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...
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...
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...
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...
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...
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...
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...