开发者

WPF Menu Open direction

I have the following menu.

        <Menu>
        <MenuItem Header="Menu1">            
            <MenuItem H开发者_JAVA技巧eader="Sub1"/>
            <MenuItem Header="Sub2"/>
            <MenuItem Header="Sub3"/>
            <MenuItem Header="Sub4"/>
        </MenuItem>
        <MenuItem Header="Menu2" />
    </Menu>

The sub-menu when opened is either in an up or down direction, is there any way I can specify the direction my self?

I'd prefer the sub-menu to always render upwards since the menu it self is on the bottom of a window.

Thanks Tony


The submenu is implemented internally using a Popup control. The default template sets the Popup's placement to Bottom which will drop the menu down if there is enough room, otherwise the menu will be "dropped up".

You can override this behavior by overriding the control template for your MenuItems. You will want to set your overridden Popup's Placement to Top.

Download the default Aero template at http://msdn.microsoft.com/en-us/library/aa972144.aspx for an example.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜