WPF 學習筆記(九)
阿新 • • 發佈:2018-08-27
toolbar 添加 mas eight click top dock horizon ima
一、菜單的創建
<Window x:Class="WpfApplication6.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> <Menu Height="23" HorizontalAlignment="Left" Margin="1"> <MenuItem Header="文件"> <MenuItem Header="打開"></MenuItem> </MenuItem> <MenuItem Header="編輯"> <MenuItem Header="後退"></MenuItem> </MenuItem> </Menu> </Grid> </Window>
二、菜單的常用布局選項 DockPanel
<Window x:Class="WpfApplication6.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> <DockPanel> <Menu DockPanel.Dock="Top"> <MenuItem Header="文件"> <MenuItem Header="打開" Click="MenuItem_Click"></MenuItem> </MenuItem> </Menu> <TextBox DockPanel.Dock="Bottom"></TextBox> </DockPanel> </Grid> </Window>
三、工具欄 關於按鈕也可以添加icon格式的圖標,<button> <button.content><image></image></button.content></button>
<Window x:Class="WpfApplication6.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> <DockPanel> <Menu DockPanel.Dock="Top"> <MenuItem Header="文件"> <MenuItem Header="打開" Click="MenuItem_Click"></MenuItem> </MenuItem> </Menu> <TextBox DockPanel.Dock="left"></TextBox> <ToolBar DockPanel.Dock="Bottom"> <Button Content="1"></Button> </ToolBar> </DockPanel> </Grid> </Window>
WPF 學習筆記(九)