如何在WPF应用程序中的菜单中显示动态SUBMENU

时间:2013-12-07 08:37:18

标签: wpf vb.net submenu

我正在尝试使用vb.net将列表绑定到WPF中的菜单。 我试过的是。 在xaml设计中:

<Window x:Class="content"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    Title="content" Height="850" Width="725" WindowStartupLocation="CenterScreen" WindowState="Maximized" >
    <Grid>


        <Menu Name="menu_wpf" >     </Menu>       

    </Grid>
</Window>

在代码背后:

 Private Sub content_Loaded(sender As Object, e As System.Windows.RoutedEventArgs) Handles Me.Loaded

    Dim lst_menu As List(Of wpf_appBAL)

    Using BAL As New wpf_appBAL
        lst_company = BAL.fill_menu(BAL)  

        menu_wpf.ItemsSource = lst_company
        menu_wpf.DisplayMemberPath = "Quantity"


    End Using

End Sub

它正确显示菜单..

现在我需要在菜单中添加子菜单 - 我该如何实现?请帮助我..

1 个答案:

答案 0 :(得分:0)

您应该实现Menu,如下所示:

<Menu Name="menu_wpf">
        <MenuItem Name="myMenuItem" Header="Quantity">
        </MenuItem>
</Menu>

并删除.vb文件中的menu_wpf.DisplayMemberPath = "Quantity"

相关问题