我无法重现你所描述的行为。我做了以下测试:
<Window x:Class="ComboWidthSample.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Height="20">
<ComboBox ItemsSource="{Binding}" Width="30" />
<ComboBox ItemsSource="{Binding}" Width="50" />
<ComboBox ItemsSource="{Binding}" Width="200" />
</StackPanel>
</Grid>
</Window>
using System.Linq;
namespace ComboWidthSample
{
public partial class Window1
{
public Window1()
{
InitializeComponent();
DataContext = Enumerable.Range(1, 10).Select(i => "My ComboBox Item " + i).ToList();
}
}
}
你在做什么不同的事情吗?也许是数据绑定到width属性,或者设计组合框的样式?