ARTICLE

SideBar Menu in WPF

Posted by Sapna Articles | WPF using VB.NET October 19, 2010
This article helps you to learn how to create SideBar Menu in WPF Application.
 
Reader Level:

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.

Login to add your contents and source code to this article
share this article :
post comment
 
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor