0
在我的WPF应用程序中,我有一个水平的StackPanel,我尝试将它用作工具栏。在这个面板中,我有按钮,组合框和文本框。由于这些按钮是最高的,StackPanel会占用它们的高度。组合框和文本框也是一样。但我希望他们保持原样,否则他们看起来很丑。我怎样才能防止他们扩大和填补所有可用的空间?我试图将其高度设置为自动或显式大小,但这没有帮助。我也尝试用Grid替换StackPanel,但这也没有帮助。我究竟做错了什么?水平堆栈面板内控件的宽度
<StackPanel Orientation="Horizontal" Margin="3, 10">
<ComboBox x:Name="Agencies" DisplayMemberPath="Name" SelectedValuePath="Value"
SelectedItem="{Binding SelectedAgency}"
Height="50" MinWidth="100" Margin="3,0"/>
<Button x:Name="UploadFile"
MinWidth="70"
Margin="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
attachProperties:ButtonIcon.Icon="Resources/Images/add.png"
Content="Upload File" IsEnabled="{Binding EnrollmentFiles.Any}"
Style="{StaticResource ImageButtonStyle}" />
<Button x:Name="EnrollmentDelete"
MinWidth="70"
Margin="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
attachProperties:ButtonIcon.Icon="Resources/Images/Remove.png"
Content="Delete Enrollment" IsEnabled="{Binding EnrollmentFiles.Any}"
Style="{StaticResource ImageButtonStyle}" />
<TextBox x:Name="WorkSheetName" />
</StackPanel>
非常感谢。 – 2012-08-02 18:25:34