一、用ViewBox实现放缩控件不变
二、布局代码
<Window x:Class="WpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="316" Width="778">
<ColumnDefinition Width="4*"/>
<ColumnDefinition Width="293*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<Label Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center">LabelLabel>
<Button Grid.Row="1" Margin="3">Button 1Button>
<Button Grid.Row="2" Margin="3">Button 2Button>
<Button Grid.Row="3" Margin="3">Button 3Button>
<Button Grid.Row="4" Margin="3">Button 4Button>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<Grid Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Top" Width="388" Height="50" Grid.RowSpan="2">
<RowDefinition Height="3*"/>
<RowDefinition Height="5*"/>
<StackPanel Grid.Row="0" Orientation="Horizontal" Margin="0,0,0,24" Grid.RowSpan="2">
<Label Height="27">标签1Label>
<TextBox Margin="5" VerticalAlignment="Center" HorizontalAlignment="Stretch" Width="Auto" Text="Search 1"/>
<Label Height="25">标签2Label>
<TextBox Margin="5" VerticalAlignment="Center" HorizontalAlignment="Stretch" Width="Auto" Text="Search 2"/>
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="2,7,2,0">
<Label Height="25">标签3Label>
<ComboBox Margin="5" VerticalAlignment="Center" Width="59">
<ComboBoxItem Content="Option 1"/>
<ComboBoxItem Content="Option 2"/>
<ComboBoxItem Content="Option 3"/>
<Label Height="26">标签4Label>
<CheckBox Margin="3" VerticalAlignment="Center" Content="Checkbox" FontSize="10" HorizontalContentAlignment="Left" VerticalContentAlignment="Center"/>
<Button Margin="30 5 5 5" VerticalAlignment="Center" Content="Search" FontSize="10"/>
<DataGrid Grid.Row="1" Margin="5,20,5,0" Height="70" VerticalAlignment="Top">
三、布局设计思路