?WPF 當窗體最大化時控件位置的大小調整:


1 <Window x:Class="WpfApplication1.MainWindow" 2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 4 FontFamily="Consolas,Microsoft Yahei" FontSize="14" 5 Title="MainWindow"> 6 <Grid> 7 <Grid x:Name="Grid1" Margin="10"> 8 <Grid.RowDefinitions> 9 <!-- 將 Grid 分為5行 其中 1、3 作為控件間的間隙 --> 10 <RowDefinition Height="Auto"/> 11 <RowDefinition Height="10"/> 12 <RowDefinition Height="*"/> 13 <!-- 也可以用 Star --> 14 <RowDefinition Height="10"/> 15 <RowDefinition Height="Auto"/> 16 </Grid.RowDefinitions> 17 18 <!-- 最上面一行放置標題和命令按鈕 --> 19 <DockPanel Grid.Row="0"> 20 <!-- 位于 0 行的控件可以省略 Grid.Row="0" --> 21 <TextBlock DockPanel.Dock="Left" Text="窗口布局" VerticalAlignment="Center"/> 22 <!-- 在 DockPanel 中最后一個定義的元素被視為 DockPanel.Dock="Fill" --> 23 <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Right"> 24 <Button Content="提交修改" Width="90" Height="23" Name="button1"/> 25 <TextBlock Text=" "/> 26 <!-- 作為 Button 的分隔符 --> 27 <Button Content="增加一列" Width="90" Height="23" Name="button2"/> 28 </StackPanel> 29 </DockPanel> 30 31 <DataGrid Grid.Row="2"/> 32 33 <Label Name="label1" Grid.Row="4"> 34 <TextBlock Text="就緒"/> 35 </Label> 36 </Grid> 37 </Grid> 38 </Window>
詳細知識參考:?
http://msdn.microsoft.com/zh-cn/library/ms754152.aspx