Windows Phone开发(33):路径之其它Geometry
原文:Windows Phone开发(33):路径之其它Geometry
上一节中,我们把最复杂的PathGeometry给干了,生剩下几个家伙就好办事了。一起来见见他们的真面目吧。
一、LineGeometry
这个几何图形就很简单了,一条线段,两个点——StartPoint And EndPoint。
一起来看看下面的例子。
<Path Grid.Column="0" Grid.Row="0">
<Path.Data>
<LineGeometry StartPoint="20,5" EndPoint="200,320"/>
</Path.Data>
</Path>
运行之后你会看到以下情景:

二、RectangleGeometry
它呈现一人矩形的几何图形,Rect指示其中矩形的位置大小,在XAML中可以用4个数值表示,即X、Y、Width、Height;别外,RadiusX和RadiusY表示圆角在X轴和Y轴上的半径。看下面的例子。
<Path Grid.Column="1" Grid.Row="0">
<Path.Data>
<RectangleGeometry Rect="12,6,125,90" RadiusX="24" RadiusY="30"/>
</Path.Data>
</Path>
运行效果如下图所示。

三、EllipseGeometry
表示一个椭圆的几何图形,Center属性为椭圆的中心点的坐标,RadiusX和RadiusY分别为X轴方向上和Y轴方向上的半径长度。看例子。
<Path Grid.Column="0" Grid.Row="1">
<Path.Data>
<EllipseGeometry Center="100,180" RadiusX="55" RadiusY="120"/>
</Path.Data>
</Path>
运行效果如下:

四、GeometryGroup
严格上说,它不属性一种几何图形,但它很有用,因为它可以同时包含N个几何图形,如下面例子所示。
<Path Grid.Column="1" Grid.Row="1">
<Path.Data>
<GeometryGroup>
<LineGeometry StartPoint="32,185" EndPoint="180,230"/>
<RectangleGeometry Rect="35,85,136,96" RadiusX="25" RadiusY="5"/>
<EllipseGeometry Center="112,130" RadiusX="45" RadiusY="36"/>
</GeometryGroup>
</Path.Data>
</Path>
运行效是如下所示:

下面是本节示例的完整XAML代码。
<phone:PhoneApplicationPage
x:Class="Sample.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True"> <phone:PhoneApplicationPage.Resources>
<Style TargetType="Path">
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="VerticalAlignment" Value="Stretch"/>
<Setter Property="Margin" Value="20"/>
<Setter Property="Stroke" Value="Blue"/>
<Setter Property="StrokeThickness" Value="8"/>
</Style>
</phone:PhoneApplicationPage.Resources> <Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Path Grid.Column="0" Grid.Row="0">
<Path.Data>
<LineGeometry StartPoint="20,5" EndPoint="200,320"/>
</Path.Data>
</Path>
<Path Grid.Column="1" Grid.Row="0">
<Path.Data>
<RectangleGeometry Rect="12,6,125,90" RadiusX="24" RadiusY="30"/>
</Path.Data>
</Path>
<Path Grid.Column="0" Grid.Row="1">
<Path.Data>
<EllipseGeometry Center="100,180" RadiusX="55" RadiusY="120"/>
</Path.Data>
</Path>
<Path Grid.Column="1" Grid.Row="1">
<Path.Data>
<GeometryGroup>
<LineGeometry StartPoint="32,185" EndPoint="180,230"/>
<RectangleGeometry Rect="35,85,136,96" RadiusX="25" RadiusY="5"/>
<EllipseGeometry Center="112,130" RadiusX="45" RadiusY="36"/>
</GeometryGroup>
</Path.Data>
</Path>
</Grid>
</phone:PhoneApplicationPage>
Windows Phone开发(33):路径之其它Geometry的更多相关文章
- Windows Phone开发(32):路径之PathGeometry
原文:Windows Phone开发(32):路径之PathGeometry 说起路径这玩意儿,其实说的就是Path类,它藏在命名空间System.Windows.Shapes下,应该好找,它有一个很 ...
- Windows Phone开发(34):路径标记语法
原文:Windows Phone开发(34):路径标记语法 如果你觉得前面所讨论的绘制各种几何图形的方法过于复杂,那么,今天我们也来一次"减负"吧.当然,我们是很轻松的,本教程是不 ...
- Kinect for Windows SDK开发入门(15):进阶指引 下
Kinect for Windows SDK开发入门(十五):进阶指引 下 上一篇文章介绍了Kinect for Windows SDK进阶开发需要了解的一些内容,包括影像处理Coding4Fun K ...
- Windows驱动开发(中间层)
Windows驱动开发 一.前言 依据<Windows内核安全与驱动开发>及MSDN等网络质料进行学习开发. 二.初步环境 1.下载安装WDK7.1.0(WinDDK\7600.16385 ...
- Windows 10开发基础——文件、文件夹和库(一)
原文:Windows 10开发基础--文件.文件夹和库(一) 主要内容: 1.枚举查询文件和文件夹 2.文本文件读写的三种方法——创建写入和读取文件 3.获得文件的属性 枚举查询文件和文件夹 先了解一 ...
- Windows Phone开发(48):不可或缺的本地数据库
原文:Windows Phone开发(48):不可或缺的本地数据库 也许WP7的时候,是想着让云服务露两手,故似乎并不支持本地数据库,所有数据都上传上"云"数据库中.不过呢,在SD ...
- Windows Phone开发(29):隔离存储C
原文:Windows Phone开发(29):隔离存储C 本文是隔离存储的第三节,大家先喝杯咖啡放松,今天的内容也是非常简单,我们就聊一件东东--用户设置. 当然了,可能翻译为应用程序设置合适一些,不 ...
- Windows Phone开发(30):图形
原文:Windows Phone开发(30):图形 图形如矩形.椭圆.路径等都从Shape类派生,它们一般表示规则或不规则图形,这些图形都是简单的二维图形,我相信大家都能理解的. 例一:矩形. 请看下 ...
- Windows Phone开发(27):隔离存储A
原文:Windows Phone开发(27):隔离存储A 在很多资料或书籍上都翻译为"独立存储",不过,我想了一下,决定将IsolatedStorage翻译为"隔离存储& ...
随机推荐
- 让XP系统支持GPT硬盘
转自 http://article.pchome.net/content-1324506-all.html 1XP系统还不过时 教你完美征服3TB硬盘回顶部 原作者:沈洁 随着高清1080p片源的普及 ...
- 与众不同 windows phone (3) - Application Bar(应用程序栏)
原文:与众不同 windows phone (3) - Application Bar(应用程序栏) [索引页][源码下载] 与众不同 windows phone (3) - Application ...
- Hibernate4读取Clob数据
package cn.framework.dao.impl; import java.io.BufferedReader; import java.io.IOException; import jav ...
- MySQL中同一时候存在创建和上次更新时间戳字段解决方法浅析
在写这篇文章之前.明白我的MySQL版本号. mysql> SELECT VERSION(); +------------+ | VERSION() | +------------+ | 5.5 ...
- DOM4J解析XML文档
Tip:DOM4J解析XML文档 Dom4j是一个简单.灵活的开放源代码的库.Dom4j是由早期开发JDOM的人分离出来而后独立开发的.与JDOM不同的是,dom4j使用接口和抽象基类,虽然Dom4j ...
- RF+Selenium2Library+Sikuli集成环境搭建
Sikuli是通过截图来编写代码的脚本语言,他是对于Selenium不好处理的一些模态窗口.flash等的利器.废话少说,直接开始安装吧.安装RF+Selenium2Library的环境这里就不说了, ...
- Linux与JVM的内存关系分析(转)
引言 在一些物理内存为8g的服务器上,主要运行一个Java服务,系统内存分配如下:Java服务的JVM堆大小设置为6g,一个监控进程占用大约600m,Linux自身使用大约800m.从表面上,物理内存 ...
- 解决编译apache出现的问题:configure: error: APR not found . Please read the documentation - ____哊.時^随记 - 51CTO技术博客
解决编译apache出现的问题:configure: error: APR not found . Please read the documentation - ____哊.時^随记 - 51CTO ...
- 访何红辉:谈谈Android源码中的设计模式
最近Android 6.0版本的源代码开放下载,刚好分析Android源码的技术书籍<Android源码设计模式解析与实战>上市,我们邀请到它的作者何红辉,来谈谈Android源码中的设计 ...
- Config File Settings Of EF——实体框架的配置文件设置
我亦MSDN 原文地址 http://msdn.microsoft.com/en-us/data/jj556606 Entity Framework allows a number of settin ...