本文介绍使用独立的xaml文件添加静态资源的方式。

步骤
  1. 创建XAML文件,如ImageButton.xaml,添加ResourceDictionary标签,并添加静态资源;
  2. 在App.xaml的Application.Resources标签中添加xaml资源文件;
  3. 在xaml界面文件中使用StaticResource使用静态资源。
示例
// ImageButton.xaml
<ResourceDictionary xmlns...>
<Style x:Key="CustomImageButton" TargetType="Button">
...
</Style>
</ResourceDictionary> // App.xaml
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/WpfApplication1;component/CustomControls/ImageButton.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources> // 使用ImageButton的xaml
<StackPanel>
<Button Width="50" Height="30" Content="Button" FontSize="14" Style="{StaticResource CustomImageButton}" />
</StackPanel>

WPF -- 一种添加静态资源的方式的更多相关文章

  1. Spring MVC—模型数据,转发重定向,静态资源处理方式

    Spring MVC处理模型数据 添加模型数据的方法 ModelAndView Map及Model SessionAttribute ModelAttribute Spring MVC转发和重定向 S ...

  2. springMvc中实现拦截器Interceptor以及添加静态资源映射

    这个代码写了很久了,多久呢?2018年12-20号写的.... 废话不多说,简化一下,作为笔记. 注: public class springmvcConfig extends WebMvcConfi ...

  3. WebConfig配置,添加静态资源,外部可以直接访问地址

    此配置是处理springboot拦截静态文件的 代码如下: @Configuration public class WebMvcConfig implements WebMvcConfigurer { ...

  4. 关于IDEA中添加静态资源(html,jpg等)后找不到资源(404 not found),以及WEB-INF目录介绍

    关于静态资源的加载 在IDEA中的java web application(或者maven项目)添加新的静态资源时(如html,jpg,gif等),常常会遇到静态资源无法加载的情况.这样的情况我们一般 ...

  5. SpringBoot中的五种对静态资源的映射规则

    目录 1.​ webjars:以jar包的方式引入静态资源 2./** 访问当前项目的任何资源 3.首页index.html,被" /** "映射 4.自定义图标 / favico ...

  6. Spring加载静态资源的方式

    解决方法1:在web.xml里添加如下的配置 <servlet-mapping> <servlet-name>default</servlet-name> < ...

  7. 8 — springboot中静态资源处理方式 - 前后端分离 这没屁用

    7中说了thymeleaf,哪还有一个目录是static 那么就来研究一下静态资源 静态资源,springboot底层是怎么去装配的,都在WebMvcAutoConfiguration有答案,去看一下 ...

  8. aiohttp之添加静态资源路径

    所谓静态资源,是指图片.js.css等文件.官方的说明在这里. 以一个小项目来说明,下面是项目的目录结构: . ├── static │ ├── css │ │ ├── base.css │ │ ├─ ...

  9. spring mvc添加静态资源访问时@Controller无效的解决

    web.xml中的url-pattern设置为/,添加mvc:resources访问静态资源时,@Controller无效的问题 web.xml: <servlet> <servle ...

随机推荐

  1. Snapshots常用命令

    HBase Snapshots允许你对一个表进行快照(即可用副本),它不会对Region Servers产生很大的影响,它进行复制和 恢复操作的时候不包括数据拷贝.导出快照到另外的集群也不会对Regi ...

  2. jmespath(1)基础语法

    前言 JMESPath是JSON的查询语言.您可以从JSON文档中提取和转换元素 官方文档:https://jmespath.org/tutorial.html 基本表达式 JMESPath用的最多的 ...

  3. Codeforces Round #533 (Div. 2) A. Salem and Sticks(枚举)

    #include <bits/stdc++.h> using namespace std; int main() { int n;cin>>n; int a[n];for(in ...

  4. 【uva 11491】Erasing and Winning(算法效率--贪心+单调队列)

    题意:有一个N位整数,要求输出删除其中D个数字之后的最大整数. 解法:贪心.(P.S.要小心,我WA了2次...)由于规定了整数的位数,那么我们要尽量让高位的数字大一些,也就是要尽量删去前面小的数字. ...

  5. poj3260 The Fewest Coins

    Description Farmer John has gone to town to buy some farm supplies. Being a very efficient man, he a ...

  6. Drone构建失败,一次drone依赖下载超时导致构建失败的爬坑记录

    Once upon a time, birds were singing in the forest, and people were dancing under the trees, It's so ...

  7. hdu 6242 Geometry Problem

    Geometry Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Other ...

  8. codeforces 878A

    A. Short Program time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...

  9. Kattis amazingadventures Amazing Adventures(费用流路径)题解

    题意: 在一个\(100*100\)的方格中,要求从\(b\)走到\(g\),途中经过\(c\)但不经过\(u\),并且不能走已经做过的路.如果可以,就求出路径. 思路: 拆点建费用流,看能不能从\( ...

  10. HDU 5608 function(莫比乌斯反演 + 杜教筛)题解

    题意: 已知\(N^2-3N+2=\sum_{d|N}f(d)\),求\(\sum_{i=1}^nf(i) \mod 1e9+7\),\(n\leq1e9\) 思路: 杜教筛基础题? 很显然这里已经设 ...