2013-07-23 51 views
0

如何建立这个......自动调整大小控制,以适应堆叠面板/固定面板,其中中间控制就是需要填充的空间

command http://img841.imageshack.us/img841/2631/46lc.jpg

在WPF

我读过很多关于使用堆栈面板vs停靠面板的其他问题,但似乎无法重新创建我想要的东西。这是我目前有..

command2 http://img13.imageshack.us/img13/5374/7oft.jpg

和我的XAML ..

<DockPanel VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Background="DarkGray" Grid.ColumnSpan="2" Grid.Row="1" LastChildFill="False" > 
      <TextBlock Text="{StaticResource commandText}" Style="{StaticResource Heading2}" Margin="0,0,0,0" VerticalAlignment="Center" DockPanel.Dock="Left" /> 
      <TextBox Name="inputTextBox" VerticalAlignment="Center" HorizontalAlignment="Stretch" /> 
      <Button x:Name="termSend" Content="{StaticResource sendText}" Margin="0,0,0,8" DockPanel.Dock="Right" VerticalAlignment="Center" /> 
     </DockPanel> 
+0

设置LastChildFill =真。这是核心功能。 –

+0

@henkholterman默认情况下是true,你不需要这个。 –

+0

但是在发布的代码中它被设置为False。 –

回答

3
<DockPanel> 
    <TextBlock VerticalAlignment="Center" Text="Command" DockPanel.Dock="Left"/> 
    <Button Content="Send" VerticalAlignment="Center" DockPanel.Dock="Right"/> 
    <TextBox VerticalAlignment="Center" Margin="5"/> 
</DockPanel> 
+0

我没有意识到这是您放入LastChildFill所执行的XAML中的最后一项,我认为这是最后一个可视化的项目。 –