我对gui有3个控件。 标签 2. textBox 3.按钮
我想让文本框出现在所有空白区域,而不是通过使用Width或MinWidth强制大小为XXX
除此之外,按钮必须出现在textBox的左侧
我的代码(我尝试使用2个面板):
<!--<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="5">
<Label VerticalAlignment="Center" VerticalContentAlignment="Bottom" Content="Target Folder:" Height="23" />
<TextBox VerticalAlignment="Center" VerticalContentAlignment="Bottom" MinWidth="500" Height="23" />
<Button VerticalAlignment="Center" VerticalContentAlignment="Bottom" Content="..." Height="23" Width="37" />
</StackPanel>-->
<DockPanel VerticalAlignment="Center" Margin="5">
<Label DockPanel.Dock="Left" VerticalAlignment="Center" VerticalContentAlignment="Center" Content="Target Folder:" Height="23" />
<TextBox DockPanel.Dock="Left" VerticalAlignment="Stretch" VerticalContentAlignment="Center" MinWidth="500" Height="23" />
<Button DockPanel.Dock="Right" VerticalAlignment="Center" VerticalContentAlignment="Center" Content="..." Height="23" Width="37" />
</DockPanel>
答案 0 :(得分:1)
<DockPanel VerticalAlignment="Center" Margin="5">
<Label DockPanel.Dock="Left" VerticalAlignment="Center" VerticalContentAlignment="Center" Content="Target Folder:" Height="23" />
<Button DockPanel.Dock="Right" VerticalAlignment="Center" VerticalContentAlignment="Center" Content="..." Height="23" Width="37" />
<TextBox VerticalAlignment="Stretch" VerticalContentAlignment="Center" MinWidth="500" Height="23" />
</DockPanel>