问题描述
如何在 Visual Studio(在 wpf 中)使用 xaml 在窗口左侧创建垂直菜单,就像 http://www.wpftutorial.net/?我试试代码:
How is it possible to create a vertical menu on the left side of the window in Visual Studio (in a wpf) with xaml like the one in http://www.wpftutorial.net/? I try the code:
<Menu DockPanel.Dock="Left" VerticalAlignment="Top" Background="Gray" BorderBrush="Black">
但它不是任务,因为它在顶部显示了一个水平菜单.
but it does not the task, since it presents a horizontal menu on the top.
不需要通过控制菜单来确定.如果任何其他外观相似的控件是合适的,则是可以接受的.
It is not required to be done definitely by the control menu. If any other control with similar appearance is appropriate, it is acceptable.
推荐答案
当然,只需将 MenuItem.ItemsPanel
更改为使用 Vertical StackPanel 而不是 Default Horizontal
Sure, just change MenuItem.ItemsPanel
to use a Vertical StackPanel instead of the Default Horizontal one
<Menu>
<Menu.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</Menu.ItemsPanel>
</Menu>
这篇关于在 Wpf 中创建垂直菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!