布局效果如下,下面每个“网格”都是一个按钮,点击按钮,就会有相应的事件发生。
由于UniformGrid
中每个Grid的尺寸相等,所以作为雷区的容器。
<DockPanel> <DockPanel.Resources> <Style TargetType="TextBlock"> <Setter Property="Margin" Value="5"/> </Style> <Style TargetType="TextBox"> <Setter Property="Margin" Value="5"/> <Setter Property="InputMethod.IsInputMethodEnabled" Value="False"/> </Style> </DockPanel.Resources> <ToolBar DockPanel.Dock="Top"> <TextBlock Text="雷区尺寸"/> <TextBox Width="40" Text="20" x:Name="txtNumX"/> <TextBlock Text="×"/> <TextBox Width="40" Text="20" x:Name="txtNumY"/> <TextBlock Text="雷数"/> <TextBox Width="40" Text="20" x:Name="txtNumMine"/> <Button Content="