This is a migrated thread and some comments may be shown as answers.

What event to handle item click ?

13 Answers 185 Views
Menu
This is a migrated thread and some comments may be shown as answers.
NS
Top achievements
Rank 1
NS asked on 07 Oct 2008, 03:10 PM
Hello,
Eg, I have a root menu called: "Root"
Root Contains two RadMenuItems (Sub1 and Sub2)

What event must I trigger to get what I've clicked in the menu ? eg, I hover to Sub1 and I click on that.

After clicking on Sub 1 I want to do something like: this.Content = new Sub1();

13 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 08 Oct 2008, 11:50 AM
Hello Nicolas,

RadMenuItem have Click event. You can handle it like this:

Sub1.Click += new RoutedEventHandler(OnSub1Click);     
private void OnSub1Click(object sender, RoutedEventArgs e)     
{     
   // you can do something here.     
}    
 

If you need more help, do not hesitate to contact us.

Best wishes,
Hristo
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
kevin
Top achievements
Rank 1
answered on 21 Oct 2008, 10:06 AM
I want to handle the click event on menu control.
But I am not able to find the Click Event..
can any one help me...?

Kevin

0
Valentin.Stoychev
Telerik team
answered on 21 Oct 2008, 03:05 PM
Hi Kevin,

The Click event is a routed event which means that it will travel down the visual tree from the MenuItem to the application's VisualRoot. It can be handled on any control along the way. Here is how you handle routed events:

public MyDemo()    
        {    
            InitializeComponent();    
    
            menu1.AddHandler(RadMenuItem.ClickEvent, new RoutedEventHandler(MenuItemClick));    
        }    
    
        private void MenuItemClick(object sender, RoutedEventArgs args)    
        {    
            RadMenuItem item = args.OriginalSource as RadMenuItem;    
        }    
 

Please note that you need to have the "Telerik.Windows" using to see the extensions methods related to handling the events.

Routed events can save a lot of time in a larger application because they allow you to handle events witout having to go through each individual object to sign up for them.

Here is a blog post on the routed events:

http://blogs.telerik.com/HristoHristov/Posts/08-07-23/Routed_Events_in_Silverlight_2.aspx?ReturnURL=%2fHristoHristov%2fPosts.aspx

Let us know if you need more questions!


Best wishes,
Valentin.Stoychev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Eric Schoenholzer
Top achievements
Rank 2
answered on 21 Oct 2008, 11:42 PM

The last example didn't work for me.

args.OriginalSource is null.

I have to use the parameter 'sender'.

 (or use "RadRoutedEventArgs args = e as RadRoutedEventArgs;" for casting the arguments, as seen in other post).

Thanks

Eric

0
yelong
Top achievements
Rank 1
answered on 12 Nov 2008, 07:35 PM

If the menu contains submenus, looks that Click event doesn't fire on the parent menu.

I had used MouseLeftButtonUp event as the work arround. but it doesn't work anymore with your last 2 releases.

Any workaround? I need to capture the Clicke event for the parent menu itselft.

Thanks,

Yelong
0
Hristo
Telerik team
answered on 13 Nov 2008, 12:49 PM
Hi Yelong,

I cannot reproduce your problem. Can you povide a sample code where Click event doesn't work?
Thanks.


Best wishes,
Hristo
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
yelong
Top achievements
Rank 1
answered on 13 Nov 2008, 06:17 PM

 

Hi there,

Thanks for you reply.

 

You can test the link below 
http://silverlight.services.live.com/invoke/66026/Debug%20Project%20for%20Telerik/iframe.html

and download the source code below

http://cid-f9a9a74fc4058aff.skydrive.live.com/self.aspx/Public/MyPublicFolder/SLDebugProject.zip

Let me know if you still can not reproduce the issue.

Thanks,

Yelong

0
Hristo
Telerik team
answered on 14 Nov 2008, 09:45 AM
Hello Yelong,

Thanks for the provided example.

We ran it locally and everything worked as expected.

When I clicked a MenuItem the RadMenu's Click event was fired and Alert window popped. The Alert window is a modal window, which means that you cannot click other controls until you close that window (the alert window).

When zooming the MapControl an exception appeared, however it did not seem to be related to our controls. We have not stated that we support such third party controls. We will continue our research on the matter and if the problem appears to be somehow related to our controls we will surely fix it right away.

Greetings,
Hristo
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
yelong
Top achievements
Rank 1
answered on 14 Nov 2008, 04:32 PM

:((

1. When you click the menu -- "Click doesn't work", you can get the popup window?
For anyone is reading this post,  could you help to test if it works in your environment from the link?
http://silverlight.services.live.com/invoke/66026/Debug%20Project%20for%20Telerik/iframe.html

2. For map control, as I said, it works with your previous release.
That's why I have posted the issue here and I am not able to upgrade to your latest.

Thanks,

0
Serrin
Top achievements
Rank 1
answered on 14 Nov 2008, 07:39 PM
I can confirm that the menu is working on my side, using latest everything on my machine right down to Silverlight tools. :)

And I've crashed the map on their own demos as well, doesn't happen all the time, but I know this isn't the first time that map control took out my entire browser. :(
0
Valentin.Stoychev
Telerik team
answered on 17 Nov 2008, 08:08 AM
Hi All,

regarding the telerik controls - the issues has been fixed - please test them with the release that is coming out this week.

Let us know how it goes.

Sincerely yours,
Valentin.Stoychev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
BlogReader
Top achievements
Rank 1
answered on 22 Sep 2009, 04:51 PM
I second yelong. The Click event is not fired if the MenuItem has other MenuItems in it.
0
BlogReader
Top achievements
Rank 1
answered on 22 Sep 2009, 04:55 PM
I just realized that in order for the event to be raised for header items, we need to set the NotifyOnHeaderClick property to True.
Tags
Menu
Asked by
NS
Top achievements
Rank 1
Answers by
Hristo
Telerik team
kevin
Top achievements
Rank 1
Valentin.Stoychev
Telerik team
Eric Schoenholzer
Top achievements
Rank 2
yelong
Top achievements
Rank 1
Serrin
Top achievements
Rank 1
BlogReader
Top achievements
Rank 1
Share this question
or