我创建了一个 Window 样式 (WPF) 并将其作为 dll 添加到我的项目中,当我运行程序时该样式正确显示,但未显示在设计器中。
我已经用谷歌搜索了,但没有一个解决方案有效
测试1:
// Window //
Style="{DynamicResource HVE_Window}"
// Window.Resources //
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/GlobalHive.Styles;component/HiveWindow.xaml"/>
</ResourceDictionary.MergedDictionaries>
结果:
Error: 'Window' TargetType doesn not match type of element 'WindowInstance'
-> But it runs and display correctly there
测试 2:
// Window //
Style="{DynamicResource MyWindow}"
// Window.Resources //
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/GlobalHive.Styles;component/HiveWindow.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style x:Key="MyWindow" TargetType="{x:Type Window}" BasedOn="{StaticResource HVE_Window}" />
结果:
No Error:
Still doesn't display in the designer, still shows up if i run the program
测试 3:
Both versions but added to application resources
它应该看起来如何:
它在设计器内部的外观: