如何在WPF中创建可扩展菜单

时间:2018-08-11 14:21:33

标签: .net wpf xaml user-controls menu-items

我是WPF应用程序开发的新手。我想创建一个单页应用程序。但是阻碍了左侧菜单的开发。目前,我正在使用普通按钮。我有以下代码库。

<UserControl x:Class="navigationApp.dashboard"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
                 xmlns:materialMenu="clr-namespace:MaterialMenu;assembly=MaterialMenu"
                 xmlns:local="clr-namespace:navigationApp"
                 mc:Ignorable="d" 
                 d:DesignHeight="650" d:DesignWidth="1120">
        <Grid >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="23*"/>
                <ColumnDefinition/>
                <ColumnDefinition Width="6*"/>
                <ColumnDefinition Width="130*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition Height="4*"/>
                <RowDefinition/>
                <RowDefinition Height="84*"/>
            </Grid.RowDefinitions>
            <Rectangle Fill="#FF00183A" Stroke="Black" Grid.ColumnSpan="4" Grid.RowSpan="3"/>
            <Image Grid.Column="1" Source="images/drawer_white.png" Grid.ColumnSpan="2" Grid.Row="1"/>
            <ContentControl Name="dashboardContentController" Content="" Grid.Column="1" Grid.Row="3" Grid.ColumnSpan="3"/>
            <Grid Grid.Row="3" Background="White">
                <Grid.RowDefinitions>
                    <RowDefinition Height="5*"/>
                    <RowDefinition Height="5*"/>
                    <RowDefinition Height="5*"/>
                    <RowDefinition Height="5*"/>
                    <RowDefinition Height="5*"/>
                    <RowDefinition Height="60*"/>
                </Grid.RowDefinitions>
                <Button Content="Dashboard" Click="Button_Click"/>
                <Button Content="Customer List" Grid.Row="1" Click="Button_Click_3"/>
                <Button Content="Customer Reg" Grid.Row="2" Click="Button_Click_1"/>
                <Button Content="Device List" Grid.Row="3" Click="Button_Click_2"/>
                <Button Content="Device Reg" Grid.Row="4" Click="Button_Click_4"/>
            </Grid>
        </Grid>
    </UserControl>

我想创建一个像这样的菜单。我们需要展开顶部菜单以查看子菜单。

deprecation

0 个答案:

没有答案