How to open new modal window in Silverlight from Telerik RadMenu

A coleague of mine asked me a question about opening modal window from RadMenu. Normally you will open some .xaml that is specified in Tag property. But how to execute some code when clicked on item in menu? To not specify a Tag is the obvious and first, what will come to your mind, but it isn’t the right one, unfortunatelly. 🙂 Going down this path, although the code in onclick eventhandler will be executed, you will be rewarded with nice exception : Value cannot be null. Parameter name : uriString.

But don’t fear, there is hope (and solution :)) and it’s not that hard.

  1. Don’t specify Tag in XAML parkup,
  2. Write OnClick eventhandler of the RadMenuItem and execute whatever code you need (instantiate modal window for example),
  3. Set Handled property of EventArgs in OnClick eventhandler to true.

Setting Handled to true means that further processing of event stops. And that’s exactly what we need. 🙂

Events in Silverlight are interesting and important thing to understand.

You can find more information about them here :

http://www.silverlightshow.net/items/Routed-Events-in-Silverlight.aspx

and here

http://msdn.microsoft.com/en-us/library/cc189018%28v=vs.95%29.aspx

Leave a Reply

Your email address will not be published. Required fields are marked *