Wednesday, March 11, 2009

Silverlight Contrib [2] - CoolMenu

The last time I have wrote about this control was Silverlight Contrib in Alfa 2. From this time have many thing changed. The most important thing was refactoring the CoolMenu. Now it inherits from ItemControl. It allows you to use some advanced things such as binding the items.

Averything about refactoring the CoolMenu read here in thre-part series by Page Brooks:
In next few rows I would like to introduce basic using of this very useful control. For information how to use Silverlight Contrib in your project in Visual Studio visit my first post about Silverlight Contrib.

In fact it is not so difficult build simple CoolMenu. You have to just define images you want to use for the menu.



Then you can enjoy the result:



That is marvelous, isn't it?

Work with items
So, let go to get a life to our menu. Our issue for this moment is: when somebody click the icon, the name of the item will be shown in upper part of page.

First thing we have to do is change structure of our menu. In case we want to work with the items we have to define CoolMenuItems more complexly.



Then we use event MunuItemClicked to show which item was clicked.



Now we can check out the result:


DataBinding
The last thing I would like to show you is how to use DataBinding for items in menu. First thing we have to do is make a class for items.



Then we have to template out item.



And finally we have to make a list of items and set ItemsSource for our menu.



That is it. Have a fun with Silverlight Contrib CoolMenu.

0 comments:

Post a Comment