C# Code Snippets  C# Code Snippets
 C# Code Snippets  C# Code Snippets
 C# Code Snippets  C# Code Snippets
 C# Code Snippets  C# Code Snippets

Saturday, December 22, 2007

How To Use Microsoft Expression Blend to Modify a Control

Hi all

Say you absolutely have to change the Button of a Combobox to a circle instead of an arrow - you just have to!!!!

Here comes Microsoft Expression Blend to the rescue, If you code in WPF and don't have it yet, you can get it here:

http://www.microsoft.com/expression/products/download.aspx?key=blend2preview

Its the beta of blend 2 but believe me when I say it feels like no beta.

Ill wait here while you download and install...

Done? Great let's start:

Open up a new project and throw in a combobox. Right click on the combobox, you should get the following context menu:

Microsoft Expression Blend

We want to press on edit a copy (picture above), which will open the next menu:

WPF Control Template 

This is Microsoft Blend's way of saying: I am going to create a new style, where would you like me to put it?

Press ok if you want it in the window's resources or select a resource dictionary if you want it to be placed there, for the sake of the example lets press OK. Now we have created a custom Combobox style. Lets right click on the Combobox toggle button, this menu pops:

Microsoft Expression Blend

We are going to select the edit template option (picture above) and that's it: we can now do whatever we want to the toggle button, like put in a red circle instead of the arrow. To do that, select the arrow by using the Direct select option from the toolbar on the left (second from top) and delete it. Insert an ellipse where the arrow used to be, and paint it red. The result is this beautiful Combobox that function exactly like the original, except it has a red circle and not an arrow:

WPF Control Template

In the same manner you can do whatever you want to any control. If you wish to see the code that Microsoft Blend wrote for you, just check out Window1.xaml or the resource dictionary you specified before

Please comment if you are experiencing problems I'll be happy to help

Enjoy

Amit

AddThis Social Bookmark Button

1 comment:

Mohan said...

but how to change the style of the control which yiu taken.I am not able to do that.