XAML 路径语法 [英] XAML Path Syntax

查看:27
本文介绍了XAML 路径语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 XAML 创建我认为的基本形状.本质上,我需要创建如下所示的内容:

I'm trying to create what I believe is a basic shape using XAML. Essentially, I need to create something that looks like the following:

______________^______________
|                            |
| Some static text will be   |
| placed here in the bubble  |
|____________________________|

目前,我有以下几点:

<Canvas x:Name="myCanvas">
  <Path Stroke="#2D2D2D" Fill="#2D2D2D"></Path>
  <TextBlock Text="Some static text will be placed here in the bubble." TextWrapping="Wrap" />
</Canvas>

显然,Path 元素的Data 部分丢失了.但是,我无法弄清楚该语法.看起来太奇怪了.我想要的只是一个矩形,在顶部边框的中间有一个三角形.这使它看起来像一个聊天气泡.有人可以解释我如何做到这一点吗?谢谢!

Obviously, the Data portion of the Path element is missing. However, I can't figure out that syntax. It seems so weird. All I want is a rectangle that has a triangle in the middle of the top border. This makes it looks like a chat bubble. Can someone explain how I can do this? Thank you!

推荐答案

为了让你学到东西,而不是仅仅给出解决方案.这与您正在寻找的内容一致;

For the sake of you learning something, as opposed to just being given a solution. This is along the lines of what you're looking for;

<Path Data="M125.11371,0.5 L141.0695,20.500002 L249.5,20.500002 L249.5,
      119.5 L0.5,119.5 L0.5,20.500002 L108.9748,20.500002 z" 
      Fill="#FF2D2D2D" Stretch="Fill" Stroke="#FF2D2D2D" 
      UseLayoutRounding="False" Width="250" Height="100"/>

他们这样做的方式是在 Expression Blend 中,我首先绘制了一个 矩形,然后使用钢笔工具绘制了一个三角形并位于前一个 矩形 的顶部中心代码>

They way I did this was in Expression Blend, I first drew a Rectangle and then using the Pen tool I drew a Triangle and positioned in the top center of the previous Rectangle

然后我选择了两个对象,并从顶部菜单中选择了对象 -> 组合 -> 联合,从而产生了最终结果.

I then selected both objects and from the top menu selected Object -> Combine -> Unite which produced this final result.

如果您更喜欢 Adob​​e Illustrator 等面向矢量的程序,则可以使用 XAML 导出器由 Mike Swanson 编写,它经常派上用场,尤其是对于比这更复杂的 XAML 设计.

If you're better with a more Vector oriented program like Adobe Illustrator, there's a XAML Exporter by Mike Swanson that comes in handy quite often, especially for more complicated XAML designs than this.

你的设计是你能想到的最简单的设计之一,所以你不会想知道为什么没有人会想要公然回答它.不过我之前遇到过你的情况,所以提供了,但希望你也学到了一些东西,当这种情况再次出现时,你可以申请.

Your design is one of the easiest you could likely come up with so you can't wonder why nobody will generally want to just answer it blatantly. However I was in your situation before so it's provided, but hopefully something was also learned you can apply when this type of situation pops up again.

希望这会有所帮助,并祝您好运.

Hope this helps and best of luck.

这篇关于XAML 路径语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆