Hi Telerik
I have a hierarchical menu like:
Menu: A
Submenus: A.1, A.2
Sub-submenus: A.1.1, A.1.2
Is it possible to get a click-event when clicking on A or A.1? Normally it only comes when clicking on A.2, A.1.1 or A.1.2.
It’s really important for one of my controls to have this function so I know at witch level in the hierarchy, that the user makes a choice that releases a click-event and leaves the menu.
Thanks from Kenneth
9 Answers, 1 is accepted
There is an easy way to achieve this. Just set NotifyOnHeaderClick="True" and the ItemClick event will be fired even if you click on parent items.
Hope this helps. Don't hesitate to contact us if you have other questions.
Kind regards,
Boyan
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Hi again
I have this menu with:
Items,
Sub-items,
Sub-sub-items,
Sub-sub-sub-items.
When a user clicks on one of the items, I simply needs to get the Headers content but I can't figure out how to read it.
I have built an event as follows:
private void RadMenu_ItemClick(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
RadMenuItem item = e.Source as RadMenuItem;
object Header = item.Header;
//I would like to be able to read the content of the header someway like although this doesn't work:
string Navn = Header.Where(n => n.Navn).ToString();
}
But I don’t know how I can read the content of Header.
I have attached an image that shows, that I want to be able to read the variable called Navn.
I hope you can help me once again :-)
With kind regards from Kenneth
Perhaps someone can suggest an easyer way of doing it?
private void RadMenu_ItemClick(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
RadMenuItem item = e.Source as RadMenuItem;
object Header = item.Header;
string Navn = "";
if (item.Items.Count > 0)
{
switch (item.Items[1].ToString())
{
case "bygdrift2.Web.Services.BygdriftServiceClasses.rumNrList_Ejendom":
Navn = ((bygdrift2.Web.Services.BygdriftServiceClasses.RumNrList)(Header)).Navn;
break;
case "bygdrift2.Web.Services.BygdriftServiceClasses.rumNrList_Sal":
Navn = ((bygdrift2.Web.Services.BygdriftServiceClasses.rumNrList_Ejendom)(Header)).Navn;
break;
case "bygdrift2.Web.Services.BygdriftServiceClasses.rumNrList_Lokale":
Navn = ((bygdrift2.Web.Services.BygdriftServiceClasses.rumNrList_Sal)(Header)).Navn;
break;
}
}
else
{
Navn = ((bygdrift2.Web.Services.BygdriftServiceClasses.rumNrList_Lokale)(Header)).Navn;
}
RadWindow.Alert("Navn is: " + Navn );
}
Thanks from Kenneth
I'd rather not have to do any form of "is open" binding.
May we receive more information on your case - which version of RadControls are you using, what exactly do you want to happen and the way you are using RadMenu? If you put all this stuff in a sample project it will be a great help for us.
Looking forward to hearing from you!
Kind regards,
Rosen Vladimirov
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
<
Grid
x:Name
=
"grid"
>
<
telerik:RadButton
>
<
telerik:RadContextMenu.ContextMenu
>
<
telerik:RadContextMenu
NotifyOnHeaderClick
=
"True"
>
<
telerik:RadMenuItem
Click
=
"RadMenuItem_Click"
>
<
telerik:RadMenuItem.Header
>
<
TextBlock
Text
=
"Parent Component"
/>
</
telerik:RadMenuItem.Header
>
<
telerik:RadMenuItem
Click
=
"RadMenuItem_Click_1"
>
<
telerik:RadMenuItem.Header
>
<
TextBlock
Text
=
"Child Component"
/>
</
telerik:RadMenuItem.Header
>
</
telerik:RadMenuItem
>
</
telerik:RadMenuItem
>
</
telerik:RadContextMenu
>
</
telerik:RadContextMenu.ContextMenu
>
<
TextBlock
Text
=
"Button"
/>
</
telerik:RadButton
>
Also, are child components suppose to notify the header when clicked?
Please add name to your contextMenu and in the parent Item click event set IsOpen property to false:
...
<
telerik:RadContextMenu
x:Name
=
"radContextMenu"
NotifyOnHeaderClick
=
"True"
>
...
private
void
RadMenuItem_Click(
object
sender, Telerik.Windows.RadRoutedEventArgs e)
{
radContextMenu.IsOpen =
false
;
}
It is expected for the children to notify their parents when they are clicked and then both click events (on the child and on the parent) are raised.
Hopefully this helps.
Kind regards,
Rosen Vladimirov
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
I do realise that being able to click on a parent Item is highly unorthodox.