C# WPF:某些表达式混合主题导致组合框绑定/显示出现错误

C# WPF:某些表达式混合主题导致组合框绑定/显示出现错误,c#,wpf,xaml,expression-blend,C#,Wpf,Xaml,Expression Blend,在我的视图模型上,我绑定到的属性是: Products = new Dictionary<string, string>(){ {"0001", "Test Product 1"}, {"0002", "Test Product 2"}, {"0003", "Test Product 3"} }; 这些主题以某种方式导致组合框同时显示键+值。这是虫子吗?有人知道如何解决吗?看起来这是XAML中的一个错误。有一个解决方法

在我的视图模型上,我绑定到的属性是:

    Products = new Dictionary<string, string>(){
        {"0001", "Test Product 1"},
        {"0002", "Test Product 2"},
        {"0003", "Test Product 3"}
    };

这些主题以某种方式导致组合框同时显示键+值。这是虫子吗?有人知道如何解决吗?

看起来这是XAML中的一个错误。有一个解决方法,但需要更改xaml:

看起来这是xaml中的一个错误。有一个解决方法,但需要更改xaml:

这是主题中的bug。您可以在主题中修改控件模板,也可以在组合框中使用ItemTemplate:

<DataTemplate x:Key="ValueDataTemplate">
   <TextBlock Text="{Binding Value}" />
</DataTemplate>

<ComboBox ItemTemplate="{StaticResource ValueDataTemplate}" SelectedValuePath="Key" 
    ItemsSource="{Binding Products}" />

这是主题中的bug。您可以在主题中修改控件模板,也可以在组合框中使用ItemTemplate:

<DataTemplate x:Key="ValueDataTemplate">
   <TextBlock Text="{Binding Value}" />
</DataTemplate>

<ComboBox ItemTemplate="{StaticResource ValueDataTemplate}" SelectedValuePath="Key" 
    ItemsSource="{Binding Products}" />

["0001","Test Product 1"]
["0002","Test Product 2"]
["0003","Test Product 3"]
<DataTemplate x:Key="ValueDataTemplate">
   <TextBlock Text="{Binding Value}" />
</DataTemplate>

<ComboBox ItemTemplate="{StaticResource ValueDataTemplate}" SelectedValuePath="Key" 
    ItemsSource="{Binding Products}" />