zoukankan      html  css  js  c++  java
  • WP独立文件资源字典

    
    
    

    有时候,开发者想把资源字典定义在单独的XAML文件中,在网上找了找,没找到比较详细的,自己弄了许久。

    1. 新建xaml资源字典文件,如在根目录下“ResourceDictionary1.xaml”,也可以建在文件夹中,只要路径对应就可以了。 

    <ResourceDictionary
    	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
      <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/TextStyle;component/ResourceDictionary1.xaml"/>
      </ResourceDictionary.MergedDictionaries>
      <!-- 应该在此定义资源字典条目。-->
        <Style x:Key="TextBlockStyle"
               TargetType="TextBlock">
            <Setter Property="Foreground"
                            Value="#474747" />
            <Setter Property="FontSize"
                            Value="40" />
            <Setter Property="FontFamily"
                            Value="{StaticResource PhoneFontFamilyNormal}" />
            <Setter Property="HorizontalAlignment"
                            Value="Left" />
            <Setter Property="VerticalAlignment"
                            Value="Top" />
        </Style>
    
    </ResourceDictionary>



    2. 在"App.xaml"下添加以下代码。

        <Application.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="ResourceDictionary1.xaml"/>
                </ResourceDictionary.MergedDictionaries>
            </ResourceDictionary>
        </Application.Resources>


    这样就可以用的地方加上

    Style="{StaticResource TextBlockStyle}"

    就可以了。


    当然,大家也可以用Blend4生成字典文件。











  • 相关阅读:
    Door Frames CodeForces
    POJ 3090 Visible Lattice Points (ZOJ 2777)
    从斐波那契到矩阵快速幂
    Recursive sequence (矩阵快速幂)2016ACM/ICPC亚洲区沈阳站
    c++ 类实现 AVL树容器(包含迭代器)
    c++ 链表类的实现(包含迭代器)
    HDU
    【几何+模拟】二次元变换 计蒜客
    【bfs+链式向前星】防御僵尸(defend)计蒜客
    deque in Python
  • 原文地址:https://www.cnblogs.com/fuhaots2009/p/3468808.html
Copyright © 2011-2022 走看看