如何使同一网格不共享整个窗口定义的列?我 想要不会停靠的网格拥有它自己的列,它将包含3个按钮
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Label Content="Temp" Grid.Row="0" FontSize="18" />
<Label Content="Date" Grid.Row="1"/>
<DatePicker Grid.Row="2" />
<Label Content="Note" Grid.Row="3" />
<TextBox Grid.Row="4" Background="WhiteSmoke"/>
<Separator Width="auto" Grid.Row="5" Margin="0 10 0 10" Background="Black"/>
<TextBox Grid.Row="6" TextWrapping="Wrap" Background="WhiteSmoke" MinHeight="150" IsReadOnly="True" />
<Label Content="Done" Grid.Row="7" />
<CheckBox Name="doneCheck" Grid.Row="7" Margin="40 7 0 0" />
<DockPanel LastChildFill="True">
<Grid DockPanel.Dock="Bottom">
<Button Content="Add" Name="SubmitButton" />
<Button Content="Get Records" Name="GetRecsButton" />
</Grid>
</DockPanel>
</Grid>
答案 0 :(得分:0)
您将DockPanel
放在外部Grid
的顶部。你必须把它放在底部:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label Content="Temp" Grid.Row="0" FontSize="18" />
<Label Content="Date" Grid.Row="1"/>
<DatePicker Grid.Row="2" />
<Label Content="Note" Grid.Row="3" />
<TextBox Grid.Row="4" Background="WhiteSmoke"/>
<Separator Width="auto" Grid.Row="5" Margin="0 10 0 10" Background="Black"/>
<TextBox Grid.Row="6" TextWrapping="Wrap" Background="WhiteSmoke" MinHeight="150" IsReadOnly="True" />
<Label Content="Done" Grid.Row="7" />
<CheckBox Name="doneCheck" Grid.Row="7" Margin="40 7 0 0" />
<DockPanel LastChildFill="True" Grid.Row="8" VerticalAlignment="Bottom" >
<Grid DockPanel.Dock="Bottom">
<Button Content="Add" Name="SubmitButton" />
<Button Content="Get Records" Name="GetRecsButton" />
</Grid>
</DockPanel>
</Grid>
当然,这意味着首先拥有DockPanel
毫无意义。但是,您可以使用DockPanel
:
<DockPanel LastChildFill="True">
<Label Content="Temp" DockPanel.Dock="Top" FontSize="18" />
<Label Content="Date" DockPanel.Dock="Top">
<DatePicker DockPanel.Dock="Top" />
<Label Content="Note" DockPanel.Dock="Top" />
<TextBox DockPanel.Dock="Top" Background="WhiteSmoke"/>
<TextBox DockPanel.Dock="Top" TextWrapping="Wrap" Background="WhiteSmoke" MinHeight="150" IsReadOnly="True" />
<Label Content="Done" DockPanel.Dock="Top" />
<CheckBox Name="doneCheck" DockPanel.Dock="Top" Margin="40 7 0 0" />
<Grid DockPanel.Dock="Bottom" >
<Button Content="Add" Name="SubmitButton" />
<Button Content="Get Records" Name="GetRecsButton" />
</Grid>
</DockPanel>