<!-- 边框样式 -->
<ComboBox x:Name="BorderTypeComboBox"
Width="75" Height="18"
Style="{StaticResource QujiaoComboxStyle}"
ItemsSource="{Binding BorderTypes}"
SelectedIndex="{Binding SelectedIndexBorderType}">
<!-- 下拉选项宽度设置 -->
<ComboBox.Resources>
<Style TargetType="Popup">
<Setter Property="Width" Value="1000"/>
<Setter Property="MinWidth" Value="200"/>
</Style>
<Style TargetType="ComboBoxItem">
<Setter Property="Width" Value="200"/>
</Style>
</ComboBox.Resources>
<ComboBox.ItemTemplate>
<DataTemplate>
<Grid>
<Image Source="{Binding Img}"
Width="Auto" Height="Auto"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
</Grid>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
在ComboBox.Resources中设置如下内容:
1.设置ComboBoxItem的宽度,使得下拉选项可以按指定宽度显示
2.设置Popup的Width为一个符合需求的最大值
3.设置Popup的MinWidth,使其与ComboBoxItem宽度保持一致
效果图: