All I wanted to do is have a ContextMenu
on a Button
with the width bounded to the Button
's width. Apparently that's too much. If you open the ContextMenu
and then decrease the size of the Button
and open it again everything's OK (the Width
gets smaller). If you increase the Width
(from 100 to 200 for example) the ContextMenu
's Width
increases too (to 200) but it only renders the previous Width
(100). I changed the Width
myself in code, used ActualWidth
instead but though the values seem fine, the context menu's rendering is poor.
Asked
Active
Viewed 909 times
1

Dave Clemmer
- 3,741
- 12
- 49
- 72
-
Tried everything i can think about, even used ScaleTransform but nothing works. I think it's probably a bug that no one came across because no one changes the size of their context menus. – Jul 27 '09 at 12:13
2 Answers
1
The width of the context menu seems to be driven by the text field length of the context item with the longest text field.
If you append a bunch of spaces to one of the context item's text field this makes both that context item and the whole context menu wider.
Everything then draws fine.
Hope this helps.

Dave Clemmer
- 3,741
- 12
- 49
- 72

Rob
- 3,488
- 3
- 32
- 27
0
Not sure if this applies, but do you have the option to use the SnapToDevicePixels=True
? I have found this makes a massive difference in rendering when it is not used... but I am not sure if the option is available on your context menu.

Dave Clemmer
- 3,741
- 12
- 49
- 72

TravisPUK
- 1,043
- 1
- 14
- 17
-
I do have the option, but it has no affect. I also tried to replace the ItemsPanelTemplate but it still rendered only a part of the ContextMenu – Jul 26 '09 at 16:55