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翻译为"隔离存储& ...
随机推荐
- Android中ProgressDialog的应用
下面通过实现点击按钮来显示加载框,2秒后自动消失. 1.首先在layout的xml中添加一个按钮: <Button android:id="@+id/button1" and ...
- windows线程同步的总结
一 线程 1)如果你正在编写C/C++代码,决不应该调用CreateThread.相反,应该使用VisualC++运行期库函数_beginthreadex,退出也应该使用_endthreadex.如果 ...
- json介绍及简单示例
JSON的定义: 一种轻量级的数据交换格式,具有良好的可读和便于快速编写的特性.业内主流技术为其提供了完整的解决方案(有点类似于正则表达式 ,获得了当今大部分语言的支持),从而可以在不同平台间进行数据 ...
- 谈VC++对象模型
一个C++程序员,想要进一步提升技术水平的话,应该多了解一些语言的语意细节.对于使用VC++的程序员来说,还应该了解一些VC++对于C++的诠释.Inside the C++ Object Model ...
- roll pitch yaw 的分别
原文地址:http://blog.sina.com.cn/s/blog_452706120100scwu.html yaw,pitch,roll这三个旋转的确切意思.如果有一个人站在(0,0,0)点, ...
- android: WheelView组件(滑轮组件)的应用!
android前段组件中, 填表单,选择条目 的样式有很多, WheelView滚动组件为其中一种,如下图所示: 前两 ...
- oc深坑測试题及其答案
一.选择题(共80题,每题1分) 1. 不会立马使引用计数器改变的是: 答案:(C) A.release B.alloc C.autorelease D.retain 2. 在OC中类的接口声 ...
- C/C++头文件
C/C++头文件 #include <assert.h> //设定插入点 #include <ctype.h> //字符处理 #include <errno.h> ...
- 44个JAVA代码质量管理工具(转)
1. CodePro AnalytixIt’s a great tool (Eclipse plugin) for improving software quality. It has the nex ...
- 图解:如何U盘装Win7系统(傻瓜式装机) + 分区步骤图解(用WIN7自带管理工具)
原地址:http://wenku.baidu.com/link?url=wV2Pfw2IM21u2KmtAcNweSZRwpXRuKAVAS29dS4aWGEpMtFdDlzZvixCgsvBxIm- ...