Unplanned
Last Updated: 21 Nov 2016 13:01 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 09 Nov 2016 11:05
Category: PageView
Type: Bug Report
1
FIX. RadPageView - duplicated menu items when adding items in the ItemListMenuDisplaying event
To reproduce: use the following code snippet:

public RadForm1()
{
    InitializeComponent();

    this.radPageView1.Pages.Add(new RadPageViewPage("My page"));
    RadPageViewStripElement stripElement = this.radPageView1.ViewElement as RadPageViewStripElement;
    stripElement.StripButtons = StripViewButtons.ItemList;

    this.radPageView1.ItemListMenuDisplaying += radPageView1_ItemListMenuDisplaying;
}

private void radPageView1_ItemListMenuDisplaying(object sender, RadPageViewMenuDisplayingEventArgs e)
{
    e.Items.Clear();
    RadMenuItem item = new RadMenuItem("aaa");
    e.Items.Add(item);
}


Click the overflow button to open the drop down and select the item. When you open the overflow popup again you will notice that the item is duplicated although you clear the items in the ItemListMenuDisplaying event.

Workaround: dispose the item when it is clicked

private void radPageView1_ItemListMenuDisplaying(object sender, RadPageViewMenuDisplayingEventArgs e)
{
    e.Items.Clear();
    RadMenuItem item = new RadMenuItem("aaa");
    item.Click += item_Click;
    e.Items.Add(item);
}

private void item_Click(object sender, EventArgs e)
{
    RadMenuItem item = sender as RadMenuItem;
    if (item != null)
    {
        item.Click -= item_Click;
        item.Dispose();
    }
}
0 comments