We want to set one MenuItem in the Items as the current selected item.
But there is no IsSelected properties in RadMenuItem (it isinternal).
And we override the RadMenuItem and override the IsHighlighted property.
Like this:
What can i do?
Any sample code is helpful~
Thanks~
But there is no IsSelected properties in RadMenuItem (it isinternal).
And we override the RadMenuItem and override the IsHighlighted property.
Like this:
public class MenuItemHousas : RadMenuItem { public MenuItemHousas() : base() { } public new bool IsHighlighted { get { return base.IsHighlighted; } set { base.IsHighlighted = value; } } }It can set the Item highlighted. But it is useless, because the current item doesn't changed.
What can i do?
Any sample code is helpful~
Thanks~
5 Answers, 1 is accepted
0
Hi Ye,
In order to select a menu item you can set the IsCurrent property of the RadMenuItem.
Best wishes,
Konstantina
the Telerik team
In order to select a menu item you can set the IsCurrent property of the RadMenuItem.
Best wishes,
Konstantina
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
0
Ye
Top achievements
Rank 1
answered on 16 Aug 2011, 04:58 AM
I don't think there is IsCurrent property in RadMenuItem that can be setted.
This proterty is not public property/
This proterty is not public property/
0
Hi Ye,
RadMenu does not support the concept of selecting the current item. When any of the submenu items is clicked, all submenus close and currently selected item cannot be shown.
What you can do to try and change this behavior, is to create your own IsCurrent DependencyProperty. In your MenuItemHousas override the ChangeVisualState method and call GoToState Current/NotCurrent state. Then, update the visual states in the style for the RadMenuItem (remember there are four templates - TopLevelHeaderTemplate, TopLevelItemTemplate, SubMenuHeaderTemplate, SubMenuItemTemplate) to reflect the new visual state change.
On ItemClick of RadMenuItem, you can wire up your own logic to set IsCurrent of the RadMenuItem to True or False.
I hope this helps.
Regards,
Dani
the Telerik team
RadMenu does not support the concept of selecting the current item. When any of the submenu items is clicked, all submenus close and currently selected item cannot be shown.
What you can do to try and change this behavior, is to create your own IsCurrent DependencyProperty. In your MenuItemHousas override the ChangeVisualState method and call GoToState Current/NotCurrent state. Then, update the visual states in the style for the RadMenuItem (remember there are four templates - TopLevelHeaderTemplate, TopLevelItemTemplate, SubMenuHeaderTemplate, SubMenuItemTemplate) to reflect the new visual state change.
On ItemClick of RadMenuItem, you can wire up your own logic to set IsCurrent of the RadMenuItem to True or False.
I hope this helps.
Regards,
Dani
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
0
Ye
Top achievements
Rank 1
answered on 18 Aug 2011, 10:57 AM
I can't call GoToState method.
Do you have any example, or any code?
Do you have any example, or any code?
0
Hello Ye,
The purpose of using the ChangeVisualState method is to include your new state, IsCurrent, in the visual states of your custom RadMenuItem. The method basically, contains a series of "if" blocks or "switch" statements that determine which visual state the menu item is in. To do that you have to call the GoToState method for the new visual state that your RadMenuItem is going to possess.
When calling the method, call base.ChangeVisualState() to have the rest of the visual states functioning. Consider the following example:
I hope this helps.
Regards,
Dani
the Telerik team
The purpose of using the ChangeVisualState method is to include your new state, IsCurrent, in the visual states of your custom RadMenuItem. The method basically, contains a series of "if" blocks or "switch" statements that determine which visual state the menu item is in. To do that you have to call the GoToState method for the new visual state that your RadMenuItem is going to possess.
When calling the method, call base.ChangeVisualState() to have the rest of the visual states functioning. Consider the following example:
public
override
void
ChangeVisualState(
bool
useTransitions)
{
if
(
this
.IsCurrent)
{
this
.GoToState(useTransitions,
new
string
[] {
"Current"
,
"NotCurrent"
});
}
else
{
this
.GoToState(useTransitions,
"NotCurrent"
);
}
}
I hope this helps.
Regards,
Dani
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>