Completed
Last Updated: 31 Mar 2014 09:07 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 20 Nov 2013 06:42
Category: CommandBar
Type: Bug Report
0
FIX. CommandBarDropDownButton with items of type RadMenuButtonItem does not have ClickedItem
To reproduce:
-add CommandBarDropDownButton and add several items of type RadMenuButtonItem;
-use the following code:
this.commandBarDropDownButton1.DropDownMenu.DropDownClosed += DropDownMenu_DropDownClosed; private void DropDownMenu_DropDownClosed(object sender, Telerik.WinControls.UI.RadPopupClosedEventArgs args) { RadDropDownMenu dropDownMenu = sender as RadDropDownMenu; if (dropDownMenu != null) { CommandBarDropDownButton commandBarDropDownButton = dropDownMenu.Owner as CommandBarDropDownButton; commandBarDropDownButton.Text = dropDownMenu.ClickedItem.Text.ToString(); } }
ClickedItem is null only in case of RadMenuButtonItem.

Workaround: public class CustomCommandBarDropDownButton : CommandBarDropDownButton { protected override void CreateChildElements() { base.CreateChildElements(); this.DropDownMenu = new CustomDropDownMenu(this); } protected override Type ThemeEffectiveType { get { return typeof(CommandBarDropDownButton); } } } public class CustomDropDownMenu : RadDropDownMenu { public CustomDropDownMenu(RadElement ownerElement) : base(ownerElement, null) { } public override string ThemeClassName { get { return typeof(RadDropDownMenu).FullName; } } protected override void OnMouseClick(MouseEventArgs e) { RadMenuItemBase menuItem = this.GetMenuItemAtPoint(e.Location); if (menuItem is RadMenuButtonItem) { FieldInfo field = typeof(RadDropDownMenu).GetField("clickedItem", BindingFlags.NonPublic | BindingFlags.Instance); field.SetValue(this, menuItem); }         base.OnMouseClick(e); } }
0 comments