zoukankan      html  css  js  c++  java
  • 使用静态资源设置UI信息

    首先建立一个文件存放样式设置(资源字典),所有风格设置都可以这里进行

    加入以下代码:

    <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
        
        <!--窗体风格设置-->
        <Style x:Key="UserWindow" TargetType="{x:Type Window}">
            <Setter Property="FontFamily" Value="微软雅黑"/>
            <Setter Property="FontSize" Value="30"/>
            <Setter Property="BorderBrush" Value="Blue"/>
            <Setter Property="FontWeight" Value="Black"/>
        </Style>
    </ResourceDictionary>
    资源字典代码

    在APP.xaml中进行以下设置 

    <Application x:Class="OilSystem.App"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                 StartupUri="ViewMainMainWindow.xaml"
                 mc:Ignorable="d">
    
        <Application.Resources>
            <!--Global View Model Locator-->
            <!--<vm:ViewModelLocator x:Key="Locator"
                                 d:IsDataSource="True" />-->
            <!--下面这行代码就是需要用到的资源字典-->
            <ResourceDictionary Source="Skins/WindowExpanderStyle.xaml"/>
        </Application.Resources>
    
    </Application>
    APP.xaml文件设置

    调用时按以下方法

    <Window x:Class="OilSystem.View.Main.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="301" Width="509" Style="{StaticResource UserWindow }">
    看Style=这样设置

    运行下看看效果吧,皮肤设置就是这样做的,更改资源字典的内容就可以直接更换风格

  • 相关阅读:
    浅析NetFilter和iptables
    关于skb_header_pointer函数
    Linux kernel 绝对路径之d_path篇
    几个内核函数:filp_open、filp_read、IS_ERR、ERR_PTR、PTR_ERR
    一文读懂数字签名
    Nginx配置文件nginx.conf中文详解(总结)
    nginx 重写 rewrite 基础及实例
    最完美解决Nginx部署ThinkPHP项目的办法
    nginx中的try_files指令解释
    js电话号码正则校验--座机和手机号
  • 原文地址:https://www.cnblogs.com/Ares-blog/p/4401040.html
Copyright © 2011-2022 走看看