WPF MVVM:整数的组合框高度不同

WPF MVVM:整数的组合框高度不同,wpf,mvvm,combobox,Wpf,Mvvm,Combobox,我正在开发一个遵循MVVM的WPF应用程序。我在应用程序中有两个组合框。一个绑定到整数列表,另一个绑定到字符串列表。问题是组合框的高度不同(见下图)。知道为什么身高不同吗?两个组合框都不涉及样式 视图: ... 视图模型: private ObservableCollection<string> _stringCollection; public ObservableCollection<string> Stringcollection => _stringC

我正在开发一个遵循MVVM的WPF应用程序。我在应用程序中有两个组合框。一个绑定到整数列表,另一个绑定到字符串列表。问题是组合框的高度不同(见下图)。知道为什么身高不同吗?两个组合框都不涉及样式

视图:


...
视图模型:

private ObservableCollection<string> _stringCollection;
public ObservableCollection<string> Stringcollection => _stringCollection ?? (_stringCollection = new ObservableCollection<string>
{
     ".igz", ".png+.png", ".jpg+.png"
});

private ObservableCollection<int> _integerCollection;
public ObservableCollection<int> IntegerCollection => _integerCollection ?? (_integerCollection = new ObservableCollection<int>
{
    8, 12, 16, 24, 32, 48, 64, 96, 128
});
private-observeCollection\u-stringCollection;
公共可观测集合Stringcollection=>\u Stringcollection??(_stringCollection=新的ObservableCollection
{
.igz“,.png+.png“,.jpg+.png”
});
私有可观测集合(integerCollection);;
公共可见集合整数集合=>\u整数集合??(_integerCollection=新的可观察集合
{
8, 12, 16, 24, 32, 48, 64, 96, 128
});

我还尝试了另一个包含枚举集合的组合框,其高度与整数组合框高度相似。

显然,默认的TextBlock样式也应用于组合框可视化树中的TextBlock。不知道为什么它只影响那些显示整数的项,而不影响那些显示字符串的项

由于您已经有了ComboBox样式,可以通过明确定义ItemTemplate轻松避免这种行为:

<Style TargetType="ComboBox" >
    <Setter Property="Margin" Value="5" />
    <Setter Property="ItemTemplate">
        <Setter.Value>
            <DataTemplate>
                <TextBlock Text="{Binding}"/>
            </DataTemplate>
        </Setter.Value>
    </Setter>
</Style>


这里只显示了故事的一半。。。该UI的其余部分在哪里?@NawedNabiZada这些是我在UI中仅有的控件。图片显示了一些东西else@NawedNabiZada添加了完整图片。您是否重新部署了组合框?如果没有,那么仍然缺少一些东西。
<Style TargetType="ComboBox" >
    <Setter Property="Margin" Value="5" />
    <Setter Property="ItemTemplate">
        <Setter.Value>
            <DataTemplate>
                <TextBlock Text="{Binding}"/>
            </DataTemplate>
        </Setter.Value>
    </Setter>
</Style>