Simple Path Data Resources that I Add to Every WPF and Silverlight Project
Here’s a little time saver. I sort of have a routine that I go through when I create a new WPF project. One of those things is to create a resource dictionary (I’m down to one on most projects now, but more on that later) that includes some common stuff that is nice to be able to depend on while your cranking out XAML.
Among those, are these super simple geometry resources:
<Geometry x:Key="DownArrow">M0,0 L1,0 0.5,1Z</Geometry>
<Geometry x:Key="UpArrow">M0,1 L1,1 0.5,0Z</Geometry>
<Geometry x:Key="RightArrow">M0,0 L1,0.5 0,1Z</Geometry>
<Geometry x:Key="LeftArrow">M0,0.5 L1,1 1,0Z</Geometry>
<Geometry x:Key="CloseX">M0,0 L1,1 M0,1 L1,0</Geometry>
Simple, but handy when you (inevitably) need to bust out an arrow for some reason. You use them like this:
<!-- DownArrow -->
<Path Data="{StaticResource DownArrow}" Width="10" Height="8"
Stretch="Fill" Fill="Black" />
<!-- CloseX -->
<Path Data="{StaticResource CloseX}" Width="12" Height="12"
Stretch="Fill" Stroke="Black" StrokeThickness="3" Margin="10" />
All together, they look like this: 
The geometries themselves all happen within a real coordinate space of a pixel, so it’s important to set the Stretch property to Fill, that way the geometry with stretch to the size of the Path element.
Unfortunately, this is WPF only. Silverlight (SL2 at least) doesn’t like to work with Geometries as resources. If someone tries it out in SL3, let me know how it goes.
Update: Dr. WPF (ironically) suggested a sweet workaround for Silverlight. Instead of adding the resources as Geometries, add them as strings, like this:
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib">
<Grid.Resources>
<sys:String x:Key="DownArrow">M0,0 L1,0 0.5,1Z</sys:String>
<sys:String x:Key="UpArrow">M0,1 L1,1 0.5,0Z</sys:String>
<sys:String x:Key="RightArrow">M0,0 L1,0.5 0,1Z</sys:String>
<sys:String x:Key="LeftArrow">M0,0.5 L1,1 1,0Z</sys:String>
<sys:String x:Key="CloseX">M0,0 L1,1 M0,1 L1,0</sys:String>
</Grid.Resources>
</Grid>
The usage from XAML is then exactly the same as WPF. Nice one, doc!
from:http://nerdplusart.com/simple-path-data-resources-that-i-add-to-every-wpf-project/
Simple Path Data Resources that I Add to Every WPF and Silverlight Project的更多相关文章
- the core of Git is a simple key-value data store The objects directory stores all the content for your database
w https://git-scm.com/book/en/v1/Git-Internals-Plumbing-and-Porcelain Git is a content-addressable f ...
- Comprehensive learning path – Data Science in Python深入学习路径-使用python数据中学习
http://blog.csdn.net/pipisorry/article/details/44245575 关于怎么学习python,并将python用于数据科学.数据分析.机器学习中的一篇非常好 ...
- UWP中String 转为Path Data
定义方法: Geometry PathMarkupToGeometry(string pathMarkup) { string xaml = "<Path " + " ...
- java.lang.ClassNotFoundException: Didn't find class "*****Activity" on path: /data/app/*******.apk
http://blog.csdn.net/lovexieyuan520/article/details/9032797/ 很多人出现了java.lang.RuntimeException: Unabl ...
- 巨坑npm run dev 报错 终于找到正确答案 Error: EPERM: operation not permitted, open '/data/public/build/css/add.p
Windows10环境 npm run dev 报错 终于找到正确答案 Error: EPERM: operation not permitted, open '/data/public/build ...
- WPF Path.Data 后台代码赋值
Path path = new Path(); string sData = "M 250,40 L200,20 L200,60 Z"; var converter = TypeD ...
- Hadoop 格式化namenode时报错警告:WARN common.Util: Path /data/dfs/name should be specified as a URI in configuration
格式化namenode时报错警告:WARN common.Util: Path /data/dfs/name should be specified as a URI in configuration ...
- Bulid过程中中遇到的问题UnityEditor.BuildPlayerWindow+BuildMethodException: '' is an incorrect path for a scene file. BuildPlayer expects paths relative to the project folder.
今天,在Bulid的过程中,遇到了一个错误“ UnityEditor.BuildPlayerWindow+BuildMethodException: '' is an incorrect path f ...
- 【转】Comprehensive learning path – Data Science in Python
Journey from a Python noob to a Kaggler on Python So, you want to become a data scientist or may be ...
随机推荐
- tmux用于恢复远程屏幕
1.我主要用tmux在远程登陆后,恢复以前会话时候用. 2.tmux创建新会话: tmux new -s 会话名 3.返回控制台: Ctrl+b d ,Ctrl+b命令是tmux前置命令,每次都要先输 ...
- iOS编程中比较两个日期的大小
转自:http://www.myext.cn/other/a_30922.html 比较日期大小是任何编程语言都会经常遇到的问题,再iOS编程中,通常用NSDate对象来存储一个时间(包括日期和时间. ...
- django——文件上传_分页_ajax_富文本_celery
上传文件 概述 当Django在处理文件上传时,文件的数据被存储在request.FILES属性中 FILES只有在请求的方法为POST且提交的form表单带有enctype="multip ...
- mysql trigger 触发器
创建触发器: CREATE [DEFINER = {user|CURRENT_USER}] TRIGGER trigger_name trigger_time trigger_event ON tbl ...
- MonoBehaviour类Invoke, Coroutine
异步函数 在一个方法执行时调用另一个方法.而被调用的方法或者其中的某些语句不是立刻执行,而是过一段时间后才执行. MonoBehaviour提供了两种异步方法 调用(Invoke) 协程(Corout ...
- IntelliJ IDEA 14.1.4导入项目启动报错:Error during artifact deployment.[组件部署期间出错]
1.问题描述:Error during artifact deployment.[组件部署期间出错] 2.删除Artifacts 3.刷新 4.重新生成Artifacts 5.重新选择 再重新启动项目 ...
- 多媒体文件格式之RMVB
[时间:2016-07] [状态:Open] RM/RMVB是Real公司私有的封装格式,常见的后缀形式是rm.ra.rmvb. 通常封装的都是real转悠的编码格式,比如音频中的sipro.cook ...
- maven pom属性 详解
pom.xml文件(实践用):<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="htt ...
- java 多线程 24 : 线程组
线程组 可以把线程归属到某一个线程组中,线程组中可以有线程对象,也可以有线程组,组中还可以有线程,这样的组织结构有点类似于树的形式,如图所示: 线程组的作用是:可以批量管理线程或线程组对象,有效地对线 ...
- python Anaconda 安装管理包,开发环境
在自己的电脑上安装Anaconda,用conda create创建一个python 2.7版本的environment.今后我们的程序都在这个环境下执行 0.download anaconda and ...