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 ...
随机推荐
- [LeetCode] Shortest Word Distance I & II & III
Shortest Word Distance Given a list of words and two words word1 and word2, return the shortest dist ...
- How to install Hadoop Cluster
https://dwbi.org/etl/bigdata/183-setup-hadoop-cluster https://www.linode.com/docs/databases/hadoop/h ...
- [Windows Azure]The Autoscaling Application Block
The Autoscaling Application Block 5 out of 6 rated this helpful - Rate this topic ...
- sessionStorage 、localStorage、cookie
特性 cookie localStorage sessionStorage 存储 浏览器端,同源限制 浏览器端,同源限制 浏览器端,同源限制 容量 <=4K 5 ...
- 每日英语:How the College Bubble Will Pop
The American political class has long held that higher education is vital to individual and national ...
- 【Linux技术】BusyBox详解
BusyBox 是很多标准 Linux® 工具的一个单个可执行实现.BusyBox 包含了一些简单的工具,例如 cat 和 echo,还包含了一些更大.更复杂的工具,例如 grep.find.moun ...
- kali下添加PATH环境变量
添加PATH环境变量,第1种方法: [root@lx_web_s1 ~]# export PATH=/usr/local/webserver/mysql/bin:$PATH 再次查看: [root@l ...
- git file mode change
近期在做ffmpeg版本合并时发现,TortoiseGit的Check for Modifications的修改对话框中有未修改的问题,直接导出diff,会有类似下面的输出: compat/plan9 ...
- 【Professional English】Words Summary
01.数据库管理系统(Database Management Systems,DBMS) A database management system (DBMS) is a computer softw ...
- linux nexus bulid
1. 将下载好的nexus-2.5.1-bundle.tar.gz包,用FTP工具传至服务器上. 2. 解压安装包 解压命令: ? 1 tar -zvxf nexus-2.5.1-bundle ...