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" > < ; 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" ></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