Suppose you have several objects in your WPF application filled with similar Brushes which differ in brightness only. Like in this image:



The nine rectangles use the same RadialGradienBrush but each rectangle is a little darker than previous. You can create these 9 different brushes in your favorite design tool (Expression Blend, etc.). But what if you need to change the base color later or you just need to make the brush user-configurable? Like in these samples:

Continue Reading...



When working with WPF I always found myself thinking how to handle Data formatting when a WPF control was bound to it. Let’s look at the following example of a window with a TextBlock that displays a DateTime:

   1: <Window x:Class="BindingFormat.Window1"

   2:     xmlns=""

   3:     xmlns:x=""

   4:     Title="Window1" Height="300" Width="300">

   5:     <Grid>

   6:         <TextBlock Text="{Binding}"></TextBlock>

   7:     </Grid>

   8: </Window>

Continue Reading...

This article was written by Alan Mendelevich




Recently I’ve been working on a set of custom WPF controls.

There are numerous good books and articles about WPF in general and some basic information on custom control development but I have yet to find a good article (or book) with in-depth coverage of custom control development in general and design-time related issues in particular.


Continue Reading...

Hey all.


Nothing new for this month so apart from reminding you that if you want to make a quick 30$ all you have to do is to drop us an good unique article (you can get more information on our Make Money Writing Articles Page). I will move on to the stats.


Here are March’s Stats:

Continue Reading...

small_flagsUntil a couple of years ago, most software applications were released in English. Unfortunately for us the developers, nowadays, many customers require that that the product they purchased, will be localized to a specific language (other than English). I know, for instance, that there is a European law which requires healthcare products to be localized to the European market (starting from 2009 or 2010). Because this article is about how to localize your application using string tables, I recommend you to first read about a free tool which helps you extract hard coded strings to string tables. Don’t go any further before you also read about how to generate public properties for string tables, you must read it.

Setting up a String Table

I assume that you already have some user interface which needs to be localized, I will demonstrate this process with…

Continue Reading...


In my previous post about WPF Binding Converters one of our readers (Thanks The Reddest) pointed our that a new converter instance is not created every time a call is made to the converter. I promised to test it again so here goes :)
I used the old converter code but added a static integer inside the converter to count the number of calls made to it. and then printed it out to the trace in the constructor.

Continue Reading...

In the previous month I have written an article about how to design a WPF custom context menu. I really liked that article because the outcome was very nice. Here comes the but :), as it turns out my implementation had a big disadvantage, it lacked the ability to show sub menus (an important trait in my opinion). So it was back to the drawing board for me.

After studying the WPF MenuItem Class and its Original Microsoft Template using blend. I learned some new things

Continue Reading...

Many times I want to make my WPF Controls have a 3D effect. For examples Headers of lists and such. Saddly there is no built in way to do it so we have to come up with a custom solution. I don’t want to use Bitmap effects due to performance reasons, I must say I don’t have much experience with them but from what I have I am not a big fan.

Here is my solution for a 3D effect on WPF Controls.

First of all a Quick demonstration. Which one looks better.

WPF 3D Border Style

I don’t know about you but the second one is much nicer with that 3D effect.

How is it done? As I said before I don’t like using Bitmap effects if I don’t have to, so this is done with combining 2 borders together. The simple upper  one is a regular border with TextBlock

Continue Reading...

We never published a lists of blog posts we liked, so this will be the first time. I gathered some links from my Google Reader shared items, some of those links are old, some are new, but I liked them all. So here is the list of 7 post/articles I recommend:

  1. Phil Haack is talking about the fact that The Design Is Never Right The First Time. I think that it is OK that the design won’t be right the first time, but it should be good at the first time. Explanation: the fact that Phil could change the implementation over night tells me that his initial design was very good. It is not that simple to change the design and the implementation so close to the deadline… I know some projects where you can’t replace some code just like that, it will take too much time to do it…
  2. Scott Hanselman tells that there is a post at the Microsoft StyleCop blog that shows some rules about directives outside and inside the namespace declaration. In his post Back to Basics – Do namespace using directives affect Assembly Loading?, he discovers that we shouldn’t believe everything we read, even on a Microsoft Blog.
  3. Jeff Atwood wrote about Dealing With Bad Apples in a team and that if you tolerate even one developer whom the other developers think is a problem, you’ll hurt the morale of the good developers. I totally agree, those situations lead to a very negative attitude in the team and after some time, it is too late because the “cancer” has spread to the whole team.

Continue Reading...

Usually, the WPF controls are declared in the .xaml file and not in the code behind (.xaml.cs file). However, we might need to use some of those controls in the code behind in order to manipulate them. How can we get the handle of such a control if it “resides” in the xaml file? Take a look at the following xaml code:

<Window x:Class="WpfApplication2.Window1"
    Title="Window1" Height="300" Width="300" MouseLeftButtonDown="window_Clicked">
        <TextBlock x:Name="fullNameControl" FontSize="20" 
                   Text="{Binding Path=FullName}">

There is a TextBlock called fullNameControl, in the code behind I change its background color to gold when the window is clicked:

Continue Reading...