留言板实例:
<Window x:Class="WpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:local="clr-namespace:WpfApp1"
mc:Ignorable="d"
Title="留言板" Height="240" Width="400">
<!--Grid>
<Button Content="打开" Name="btnCtrlOpen" Click="btnCtrlOpen_Click" HorizontalAlignment="Left" Margin="310,115,0,0" VerticalAlignment="Top" Width="75" />
<Button Content="关闭" Name="btnCtrlClose" HorizontalAlignment="Left" Margin="495,115,0,0" VerticalAlignment="Top" Width="75" Click="BtnCtrlClose_Click"/>
<Button Content="设置" Name="btnCtrlSet" HorizontalAlignment="Left" Margin="415,200,0,0" VerticalAlignment="Top" Width="75"/>
<Label Content="显示标签" Name="lblShow" HorizontalAlignment="Left" Margin="170,115,0,0" VerticalAlignment="Top"/>
<Rectangle Name="Rec1" Width="200" Height="120" Fill="Blue" Margin="250,50,100,50" RadiusX="0.75" RadiusY="0.75"/>
</-->
<!--<Canvas Margin="50,50,50,50" Background="White" >
<Rectangle Name="rect" Canvas.Left="300" Canvas.Top="180" Fill="Black" Stroke="Red" Width="200" Height="200"/>
<Ellipse Name="el" Canvas.Left="160" Canvas.Top="150" Fill="Azure" Stroke="Green" Width="180" Height="180"/>
</Canvas>-->
<!--<StackPanel Margin="10,10,10,10" Background="Azure" Orientation="Vertical">
<Label>A Button Stack</Label>
<Button Content="Button 1"></Button>
<Button>Button 2</Button>
<Button>Button 3</Button>
<Button Content="Button 4"></Button>
<Button Content="Button 5"/>
</StackPanel>-->
<!--<WrapPanel Margin="10" Background="Azure">
<Button VerticalAlignment="Top" Margin="5">Top Button</Button>
<Button MinHeight="50">Tall Button 2</Button>
<Button VerticalAlignment="Bottom">Bottom Button</Button>
<Button>Stretch Button</Button>
<Button VerticalAlignment="Center">Center Button</Button>
<Button>Next Button</Button>
</WrapPanel>-->
<!--<DockPanel Margin="10" Background="Azure" LastChildFill="True">
<Button DockPanel.Dock="Top" Background="Red">Top Button</Button>
<Button DockPanel.Dock="Left" Background="Gray">Left Button</Button>
<Button DockPanel.Dock="Right" Background="Green">Right Button</Button>
<Button DockPanel.Dock="Bottom" Background="White">Bottom Button</Button>
<Button>Remaining Button</Button>
</DockPanel>-->
<!--<Grid Width="Auto" Height="Auto">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="150"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<Rectangle Grid.Row="0" Grid.Column="0" Fill="Green" Margin="10,10,10,20"/>
<Rectangle Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" Fill="Blue" Margin="10,10,10,20"/>
<Rectangle Grid.Row="0" Grid.Column="4" Fill="Orange"/>
<Button Grid.Row="1" Grid.Column="0">Button 2</Button>
<Rectangle Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" Fill="Red"/>
</Grid>-->
<!--<UniformGrid>
<Ellipse Margin="10" Fill="Gray"/>
<Ellipse Margin="10" Fill="Gray"/>
<Ellipse Margin="10" Fill="Green"/>
<Ellipse Margin="10" Fill="Green"/>
<Ellipse Margin="10" Fill="Red"/>
</UniformGrid>-->
<!--<StackPanel>
<TextBox x:Name="textBox" Margin="5"/>
<Button Content="OK" Margin="5" Click="Button_Click"/>
</StackPanel>-->
<!--<Grid Background="Azure">
--><!--<ListBox Margin="5" ItemsSource="{x:Array Type=sys:String}"/>-->
<!--<ListBox Margin="5" ItemsSource="{x:Array Type=sys:String}"/>--><!--
<ListBox Margin="10,10,600,10">
<ListBox.ItemsSource>
<x:Array Type="sys:String">
<sys:String>tom1</sys:String>
<sys:String>tom2</sys:String>
</x:Array>
</ListBox.ItemsSource>
</ListBox>
<Button Content="Button" HorizontalAlignment="Left" Margin="217,10,0,0" VerticalAlignment="Top" Width="85" Height="46"/>
<Button Margin="217,77,475,292" Height="50" Width="100">
--><!--<TextBlock Text="hello"/>--><!--
<Image Source="C:\Users\admin\source\repos\WpfApp1\WpfApp1\bin\Debug\start.png"/>
</Button>
</Grid>-->
<Grid Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="80"/>
<ColumnDefinition Width="4"/>
<ColumnDefinition Width="80"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
<RowDefinition Height="4"/>
<RowDefinition Height="*"/>
<RowDefinition Height="4"/>
<RowDefinition Height="25"/>
</Grid.RowDefinitions>
<TextBlock Text="请选择您的部门并留言:" Grid.Column="0" Grid.Row="0" VerticalAlignment="Center"/>
<ComboBox Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="4"/>
<TextBox Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="5" BorderBrush="Black"/>
<Button Content="提交" Grid.Column="4" Grid.Row="2"/>
<Button Content="清除" Grid.Column="4" Grid.Row="4"/>
</Grid>
</Window>
运行结果: