Representing Geometries as Strings

Representing each segment in a Geometry with a separate element is fine for simple shapes and paths or geometries formed dynamically in procedural code. For complicated artwork in XAML, however, it can get extremely verbose. Although most people use a design tool to emit XAML-based geometries anyway rather than craft them by hand, it makes sense to keep the resultant file size as small as reasonably possible.

Therefore, XAML supports a flexible syntax for representing just about any PathGeometry as a string. The PathGeometry representing the simple triangle displayed in Figure 7.11:

<Path Fill="Orange" Stroke="Black" StrokeThickness="10">  <Path.Data>    <PathGeometry>       <

Get XAML Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.