我有一个Windows 8.1应用程序。Windows Store应用程序未能创建样式BasedOn共享样式
在Project.Shared有资源字典SharedResources.xaml
与基本样式,
<Style x:Key="CommonLayerListItemStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="Segoe WP" />
<Setter Property="Foreground" Value="{StaticResource UnselectBrush}" />
<Setter Property="VerticalAlignment" Value="Stretch" />
</Style>
在Windows Phone应用程序
是在此基础上
<Style x:Key="LayerListItemStyle"
BasedOn="{StaticResource CommonLayerListItemStyle}"
TargetType="TextBlock">
<Setter Property="FontSize" Value="20" />
</Style>
同样在Windows应用程序StyleResources.xaml
StyleResources.xaml
风格室内用:
<Style x:Key="LayerListItemStyle"
BasedOn="{StaticResource CommonLayerListItemStyle}"
TargetType="TextBlock">
<Setter Property="FontSize" Value="28" />
<Setter Property="Margin" Value="42,0,0,0" />
</Style>
使用所有样式在共享项目中创建的UserControl中。 我这样做是为了覆盖不同平台上的FontSize。
我合并了App.xaml中
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Styles/SharedResources.xaml" />
<ResourceDictionary Source="Styles/StyleResources.xaml" />
</ResourceDictionary.MergedDictionaries>
所有词典但我的应用程序不会有未处理的异常 Cannot find a Resource with the Name/Key CommonLayerListItemStyle [Line: 10 Position: 37]
为什么会出现这种情况开始?
请参阅[这里] [1]问题的接受的答案下面的评论。 [1]:http://stackoverflow.com/questions/1652420/wpf-use-a-controltemplate-resource-within-a-style – KenIchi 2015-03-12 10:53:09