定义XAML通用应用的样式

2014-05-19  籽藤 

参见《Sharing Resource Dictionaries in your Universal XAML Apps》 http://blog.falafel.com/Blogs/bary-nusz/2014/04/27/sharing-resource-dictionaries-in-your-universal-xaml-apps

我的项目结构如图:

在App.xaml中配置好样式文件的路径。那么Windows 8.1 App和Windows Phone 8.1 App就会使用各自项目中该路径下的style.xaml中的样式。

<Application.Resources> <!-- Application-specific resources --> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <!-- Styles that define common aspects of the platform look and feel Required by Visual Studio project and item templates --> <ResourceDictionary Source="/Styles/style.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources>

style.xaml

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Style x:Key="BasicTextStyle" TargetType="TextBlock" BasedOn="{StaticResource BaseTextBlockStyle}"> <Setter Property="FontWeight" Value="Normal"/> <Setter Property="Margin" Value="0,0,0,10"/> </Style> </ResourceDictionary>
380°/3809 人阅读/0 条评论 发表评论

登录 后发表评论