Xaml WPF中的QT垫片当量

Xaml WPF中的QT垫片当量,xaml,stackpanel,Xaml,Stackpanel,我有一个StackPanel,带有一些垂直对齐的控件(图中右侧的StackPanel: 最后一个控件应始终放置在边框控件(图片上的“确定”按钮)内的窗口底部。在QT中,我将插入一个间隔控件来按下按钮。在WPF中如何操作?谢谢。以下是xaml: <Window x:Class="Test.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="h

我有一个StackPanel,带有一些垂直对齐的控件(图中右侧的StackPanel:

最后一个控件应始终放置在边框控件(图片上的“确定”按钮)内的窗口底部。在QT中,我将插入一个间隔控件来按下按钮。在WPF中如何操作?谢谢。以下是xaml:

<Window x:Class="Test.MainWindow"
       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
       Title="MainWindow" Height="350" Width="525">
    <Grid>
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="354*" />
      <ColumnDefinition Width="Auto" />
    </Grid.ColumnDefinitions>

    <Border Margin="5" Background="Gray" CornerRadius="6" BorderBrush="Gray">
      <Viewport3D Grid.Column="0" Name="viewport" ClipToBounds="True">
      </Viewport3D>
    </Border>

    <Border Grid.Column="1" CornerRadius="6" BorderBrush="Gray" Background="LightGray" BorderThickness="1" Margin="5" HorizontalAlignment="Left" Name="border1" VerticalAlignment="Stretch" >
      <StackPanel>
        <StackPanel Orientation="Horizontal">
          <Label Content="Dimension" Name="label1" VerticalAlignment="Center" />
          <ComboBox Text="3D" HorizontalAlignment="Right" Name="dimensioncb" VerticalAlignment="Center" IsReadOnly="True" IsEditable="True">
            <ComboBoxItem>2D</ComboBoxItem>
            <ComboBoxItem>3D</ComboBoxItem>
          </ComboBox>
        </StackPanel>
        <Separator/>
        <DockPanel>
          <Label Content="Iteration" Name="label2" VerticalAlignment="Center" />
          <ComboBox Text="3" HorizontalAlignment="Right" Name="iterationcb" VerticalAlignment="Center" IsReadOnly="True" IsEditable="True">
            <ComboBoxItem>1</ComboBoxItem>
            <ComboBoxItem>2</ComboBoxItem>
            <ComboBoxItem>3</ComboBoxItem>
            <ComboBoxItem>4</ComboBoxItem>
            <ComboBoxItem>5</ComboBoxItem>
            <ComboBoxItem>6</ComboBoxItem>
            <ComboBoxItem>7</ComboBoxItem>
            <ComboBoxItem>8</ComboBoxItem>
          </ComboBox>
        </DockPanel>
        <Button Content="OK" VerticalAlignment="Bottom"/>
      </StackPanel>
    </Border>

  </Grid>
</Window>

二维
三维
1.
2.
3.
4.
5.
6.
7.
8.

在WPF中有很多方法可以实现这一点。如下所示是其中之一:

<Border Grid.Column="1" CornerRadius="6" BorderBrush="Gray" Background="LightGray" BorderThickness="1" Margin="5" HorizontalAlignment="Left" Name="border1" VerticalAlignment="Stretch" >
  <!--Add a grid control to separate your stackpanel and button-->
  <Grid>
    <Grid.RowDefinitions>
       <RowDefinition Height="*"/>
       <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>
  <StackPanel Grid.Row="0">
    <StackPanel Orientation="Horizontal">
      <Label Content="Dimension" Name="label1" VerticalAlignment="Center" />
      <ComboBox Text="3D" HorizontalAlignment="Right" Name="dimensioncb" VerticalAlignment="Center" IsReadOnly="True" IsEditable="True">
        <ComboBoxItem>2D</ComboBoxItem>
        <ComboBoxItem>3D</ComboBoxItem>
      </ComboBox>
    </StackPanel>
    <Separator/>
    <DockPanel>
      <Label Content="Iteration" Name="label2" VerticalAlignment="Center" />
      <ComboBox Text="3" HorizontalAlignment="Right" Name="iterationcb" VerticalAlignment="Center" IsReadOnly="True" IsEditable="True">
        <ComboBoxItem>1</ComboBoxItem>
        <ComboBoxItem>2</ComboBoxItem>
        <ComboBoxItem>3</ComboBoxItem>
        <ComboBoxItem>4</ComboBoxItem>
        <ComboBoxItem>5</ComboBoxItem>
        <ComboBoxItem>6</ComboBoxItem>
        <ComboBoxItem>7</ComboBoxItem>
        <ComboBoxItem>8</ComboBoxItem>
      </ComboBox>
    </DockPanel>
  </StackPanel>
    <Button Grid.Row="1" Content="OK" VerticalAlignment="Bottom"/>
  </Grid>
</Border>

二维
三维
1.
2.
3.
4.
5.
6.
7.
8.
上述XAML用于替换XAML中右侧的
边框
,将产生以下结果,并在重新调整窗口大小时将按钮保持在底部