This is a migrated thread and some comments may be shown as answers.

Width of ContextMenu

1 Answer 391 Views
ContextMenu
This is a migrated thread and some comments may be shown as answers.
Fritz
Top achievements
Rank 1
Fritz asked on 21 May 2010, 05:34 PM
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 ?

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 27 May 2010, 08:50 AM
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,
Nikolay
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.
Tags
ContextMenu
Asked by
Fritz
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or