WPF SideBar Menu in VB.NET

This article helps you to learn how to create SideBar Menu in WPF Application.
  • 3972

You can apply different styles to your menu items like designing a SideBar menu. You can create it by supplying a StackPanel for the ItemsPanel property changing its background, and wrapping the entire Menu in a ScrollViewer. Lets see the code snippets to learn how to create a SideBar Menu in WPF Application.

SideBar Menu

<Window x:Class="MenusAndToolbars.SidebarMenu"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.mirosoft.com/winfx/2006/xaml"
    Title="SidebarMenu" Height="300" Width="400">
    <DockPanel LastChildFill="True" Margin="5">
        <Border BorderBrush="SteelBlue" BorderThickness="1">
            <ScrollViewer DockPanel.Dock="Left">
                <Menu>
                    <Menu.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel Background="White"></StackPanel>
                        </ItemsPanelTemplate>
                    </Menu.ItemsPanel>
                    <MenuItem Header="File">
                        <MenuItem Header="New"></MenuItem>
                        <MenuItem Header="Open"></MenuItem>
                        <MenuItem Header="Save"></MenuItem>
                    </MenuItem>
                    <MenuItem Header="Edit">
                        <MenuItem Header="Cut"></MenuItem>
                        <MenuItem Header="Copy"></MenuItem>
                        <MenuItem Header="Paste"></MenuItem>
                    </MenuItem>
                    <MenuItem Header="Help">
                        <MenuItem Header="How do I"></MenuItem>
                        <MenuItem Header="Search"></MenuItem>
                        <MenuItem Header="Index"></MenuItem>
                    </MenuItem>                    </Menu>
            </ScrollViewer>
        </Border>
 
        <TextBox Margin="5,0,0,0" TextWrapping="Wrap">Other content goes here.</TextBox>
    </DockPanel>
</Window>

OUTPUT

sidebar-menu.gif

I hope this will help you.

Categories

More Articles

© 2013 dotNetheaven. All rights reserved.