Hi,
I want to create context menu in cs file.(not in xaml file)
all your exampels in the web site for context menu this in xaml files.
i write:
and the context menu don't show on the screen.
How I do it????
I want to create context menu in cs file.(not in xaml file)
all your exampels in the web site for context menu this in xaml files.
i write:
RadContextMenu radContextMenu1 = new RadContextMenu(); |
radContextMenu1.ClickToOpen = true; |
radContextMenu1.EventName = "Click"; |
firstLevel = new RadMenuItem(); |
firstLevel.Header = "aa"; |
firstLevel.Icon = new Image() { Source = new BitmapImage(new Uri("no-drag.png", UriKind.Relative)) }; |
firstLevel.Click += new RoutedEventHandler(firstLevel_Click); |
firstLevel.SubmenuClosed += new RoutedEventHandler(firstLevel_SubmenuClosed); |
(firstLevel_SubmenuOpened); |
radContextMenu1.Items.Add(firstLevel); |
How I do it????
6 Answers, 1 is accepted
0
Hello Ruty,
The context menu needs to be set as an attached property to the element that should be his parent. To set attached properties in code, the similarly-named static methods are used, in your case you need to add:
Where someVisualElement can be any visual element that exposes an event with the chosen name.
Greetings,
Miroslav
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.
The context menu needs to be set as an attached property to the element that should be his parent. To set attached properties in code, the similarly-named static methods are used, in your case you need to add:
RadContextMenu.SetContextMenu(someVisualElement, radContextMenu1); |
Where someVisualElement can be any visual element that exposes an event with the chosen name.
Greetings,
Miroslav
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
ruty
Top achievements
Rank 1
answered on 30 Mar 2009, 07:12 AM
Thanks,
I do it, but i get error "click event can not be found".
my code is:
RadContextMenu buttonContextMenu = new RadContextMenu(); |
buttonContextMenu.EventName = "Click"; |
RadMenuItem item1 = new RadMenuItem() |
{ |
Header = "Statuses" |
}; |
RadMenuItem item11 = new RadMenuItem() |
{ |
Header = "Open" |
}; |
item1.Items.Add(item11); |
RadMenuItem item12 = new RadMenuItem() |
{ |
Header = "New" |
}; |
item1.Items.Add(item12); |
RadMenuItem item13 = new RadMenuItem() |
{ |
Header = "Cancelled" |
}; |
item1.Items.Add(item13); |
buttonContextMenu.Items.Add(item1); |
RadContextMenu.SetContextMenu(taskRectangle, buttonContextMenu); |
Thanks.
0
Hello ruty,
The EventName should be event that exist on the element that you attach the context menu.
From your code it looks like you are attaching it to Rectange. The rectangle doesn't have Click event. This is why you receive this error. For the rectangle you can you MouseLeftButtonDown or MouseLeftButtonUp events.
Let us know if you need more information.
All the best,
Hristo
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.
The EventName should be event that exist on the element that you attach the context menu.
From your code it looks like you are attaching it to Rectange. The rectangle doesn't have Click event. This is why you receive this error. For the rectangle you can you MouseLeftButtonDown or MouseLeftButtonUp events.
Let us know if you need more information.
All the best,
Hristo
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
ruty
Top achievements
Rank 1
answered on 31 Mar 2009, 04:58 AM
Thanks,
Your answer help me.
I want to ask more question:
I want to set contexet menu when the user click on right button mouse.
It is possible in telerik???
Thanks.
Your answer help me.
I want to ask more question:
I want to set contexet menu when the user click on right button mouse.
It is possible in telerik???
Thanks.
0
Hi ruty,
Yes it is possible but you need to run your Silverlight application in windowless mode. Just add the bold line in the silverlight object tag (your html or aspx page).
You don't need to change the EventName - the default value (MouseRightButtonDown) will do the job.
Let us know if you need more help.
Regards,
Hristo
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Yes it is possible but you need to run your Silverlight application in windowless mode. Just add the bold line in the silverlight object tag (your html or aspx page).
<div id="silverlightControlHost"> |
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%"> |
<param name="source" value="ClientBin/SilverlightApplication31.xap"/> |
<param name="onerror" value="onSilverlightError" /> |
<param name="background" value="white" /> |
<param name="minRuntimeVersion" value="2.0.31005.0" /> |
<param name="autoUpgrade" value="true" /> |
<param name="windowless" value="true" /> |
<a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;"> |
<img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/> |
</a> |
</object> |
<iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe> |
</div> |
You don't need to change the EventName - the default value (MouseRightButtonDown) will do the job.
Let us know if you need more help.
Regards,
Hristo
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Joshua Huang
Top achievements
Rank 1
answered on 21 Sep 2009, 03:53 PM
Hi,
I am having problem with the radcontextmenu mouse right click as well. I can have the mouse left click, mouse over, or fired by isOpen=true work to show the context menu. But the mouse right click just never working, even if I use windowless. Please help. Thanks!