【发布时间】:2023-09-05 13:09:01
【问题描述】:
解析一个 xaml 文件时出现异常:
结果消息:
测试方法 ThemeResourceDictionaryTest.ParseXaml 抛出异常: System.Windows.Markup.XamlParseException:'向'System.Windows.ResourceDictionary'类型的字典添加值引发异常。'行号“1397”和行位置“4”。 ---> System.ArgumentException:项目已被添加。在字典中键入:'System.Windows.Controls.TextBox' 正在添加的键:'System.Windows.Controls.TextBox'
和我的元素:
<Style x:Key="MyVeryUniqueKey" BasedOn="{StaticResource TextBoxStyle}" TargetType="TextBox">
<Setter Property="MinWidth" Value="90"/>
</Style>
为什么元素的key设置为TextBox,而我显式设置key为唯一的MyVeryUniqueKey时。
我还有其他样式,其目标类型是 TextBox,但它们都有不同的键。
【问题讨论】:
标签: c# wpf xaml resourcedictionary