WPF与WINFORMS控件的比较

时间:2009-07-29 17:53:08

标签: wpf winforms menustrip

我们在Winform中使用“layoutstyle”属性将layoutstyle更改为horrizontal / vertical(所有标题和子菜单),在WPF中使用什么来获得相同的结果。

1 个答案:

答案 0 :(得分:2)

您可以为菜单添加一个新的ItemsPanelTemplate:

<Menu>
    <Menu.ItemsPanel>
        <ItemsPanelTemplate>
            <VirtualizingStackPanel Orientation="Vertical"/>
        </ItemsPanelTemplate>
    </Menu.ItemsPanel>
    <MenuItem Header="File"/>
    <!-- Other menu items -->
</Menu>

这会垂直排列您的菜单项。