Width of ContextMenu

2 posts, 0 answers
  1. fbi
    fbi avatar
    4 posts
    Member since:
    Oct 2009

    Posted 21 May 2010 Link to this post

    I have created a ContextMenu with two buttons.
    But if I show the ContextMenu not all of the button is shown.
    How can I set the width of the ContextMenu ?
  2. Nikolay
    Nikolay avatar
    1805 posts

    Posted 27 May 2010 Link to this post

    Hello fbi,

    Thank you for the question.

    Generally, you can set the size of the context menu by setting the MinSize and MaxSize properties as shown below:
    this.radContextMenu1.DropDown.RootElement.Children[0].Children[3].Children[1].MinSize = new Size(400, 0);

    However, the size of the buttons is calculated by the size of the dropdown and this calculation is not correct even when you set a bigger size. In order to get the correct behavior, you need to set the Margin property of the buttons contained in the RadMenuButtonItems:
    for (int i = 0; i < this.radContextMenu1.Items.Count; i++)
        if (this.radContextMenu1.Items[i] is RadMenuButtonItem)
            ((RadMenuButtonItem)this.radContextMenu1.Items[i]).ButtonElement.Margin = new Padding(0, 0, 5, 0);

    I hope this helps. If you have additional questions, feel free to contact me.

    All the best,
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top