WPF's menu bar, toolbar simple to use

Source: Internet
Author: User

1. The interface effect is as follows:

2. Page. The XAML code is as follows:
<window x:class= "Menuandtoolbar.mainwindow" xmlns= "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x= "Http://schemas.microsoft.com/winfx/2006/xaml" title= "MainWindow" height= "width=" "525" > &lt ;                grid> <DockPanel><!--Docking Layout so that the menu bar and toolbar are at the top of the window-<menu dockpanel.dock= "Top" > <menuitem header= "File" ><!--menu item is MenuItem, Text uses properties header--> <menuitem name= "Menuopen" Header= "Open" click= "Menuopen_click" ></MenuItem> <menuitem header= "Save" &GT;&LT;/MENUITEM&G                    T <menuitem header= "Delete" ></MenuItem> </MenuItem> <menuitem header= "Edi T "></MenuItem> <menuitem header=" View "></MenuItem> <menuitem header= "About" ></MenuItem> </Menu> <toolbar dockpanel.dock= "Top" ><!--ToolBar and status BaR is a container--<button content= "Save" ></Button> <button content= "SaveAll" >& lt;/button> <button content= "FileExplorer" ></Button> <button content= "Star T "></Button> <button content=" Test "></Button> </ToolBar> & Lt TextBox dockpanel.dock= "Top" text= "This is My Space" height= "243" ></TextBox> <statusbar DOCKPANEL.D        ock= "Bottom" > <textblock text= "StatusBar" ></TextBlock> </StatusBar> </DockPanel> </Grid></Window>
3. Background code:
Using system;using system.collections.generic;using system.linq;using system.text;using System.Threading.Tasks; Using system.windows;using system.windows.controls;using system.windows.data;using system.windows.documents;using System.windows.input;using system.windows.media;using system.windows.media.imaging;using System.windows.navigation;using system.windows.shapes;namespace menuandtoolbar{///<summary>///Interaction Logic for mainwindow.xaml///</summary> public    partial class Mainwindow:window    {public          MainWindow ( )         {               InitializeComponent ();         }          private void Menuopen_click (object sender, RoutedEventArgs e)          {                MessageBox.Show ("Open the file you want.");          }}

  

 

WPF menu bar, toolbar simple to use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.