gpt4 book ai didi

c# - WPF:一些 Expression Blend 主题导致 Combobox 绑定(bind)/显示中的错误

转载 作者:太空宇宙 更新时间:2023-11-03 21:23:52 25 4
gpt4 key购买 nike

在我的 View 模型中,我绑定(bind)的属性是:

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

在我的 xaml 中,我有以下绑定(bind):

<ComboBox Grid.Row="1" Grid.Column="1" DisplayMemberPath="Value" SelectedValuePath="Key" VerticalAlignment="Center" 
ItemsSource="{Binding Path=DataContext.Products, RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}}"/>

此外,在我的 xaml 中我加载了我的资源字典,包括这样的表达式混合主题:

<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="AppResourceDict.xaml" />
<ResourceDictionary Source="Themes/ExpressionLight.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>

上面的效果很好。但是,如果我将“Themes/ExpressionLight.xaml”更改为“Themes/BureauBlue.xaml”或“Themes/BureauBlack.xaml”,组合框下拉列表中显示的是:

["0001","Test Product 1"]
["0002","Test Product 2"]
["0003","Test Product 3"]

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

最佳答案

看起来这是 XAML 中的错误。有一个解决方法,但它需要更改 xaml:https://wpf.codeplex.com/workitem/10129

关于c# - WPF:一些 Expression Blend 主题导致 Combobox 绑定(bind)/显示中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28689788/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com