mirror of
https://github.com/Stone-Red-Code/docs-desktop.git
synced 2026-09-05 16:06:10 +02:00
* Reset branch for WPF changes * Convert BMP to PNG; fix link-out-of-scope err * Add snippets for WPF... 6794 files!!!! * Add missing snippets * update file updated between migration * Fix paths to include * update breadcrumb and toc * fix index links * fix index links * fix index links * fix markdown
32 lines
2.5 KiB
Markdown
32 lines
2.5 KiB
Markdown
---
|
|
title: "How to: Create a GeometryDrawing"
|
|
ms.date: "03/30/2017"
|
|
helpviewer_keywords:
|
|
- "shapes [WPF], renderable"
|
|
- "renderable shapes [WPF]"
|
|
- "graphics [WPF], GeometryDrawing class"
|
|
- "classes [WPF], GeometryDrawing"
|
|
ms.assetid: 11d3c096-91ba-4d41-9bba-aeac0db70f97
|
|
---
|
|
# How to: Create a GeometryDrawing
|
|
This example shows how to create and display a <xref:System.Windows.Media.GeometryDrawing>. A <xref:System.Windows.Media.GeometryDrawing> enables you to create shape with a fill and an outline by associating a <xref:System.Windows.Media.Pen> and a <xref:System.Windows.Media.Brush> with a <xref:System.Windows.Media.Geometry>. The <xref:System.Windows.Media.GeometryDrawing.Geometry%2A> describes the shape's structure, the <xref:System.Windows.Media.GeometryDrawing.Brush%2A> describes the shape's fill, and the <xref:System.Windows.Media.GeometryDrawing.Pen%2A> describes the shape's outline.
|
|
|
|
## Example
|
|
The following example uses a <xref:System.Windows.Media.GeometryDrawing> to render a shape. The shape is described by a <xref:System.Windows.Media.GeometryGroup> and two <xref:System.Windows.Media.EllipseGeometry> objects. The shape's interior is painted with a <xref:System.Windows.Media.LinearGradientBrush> and its outline is drawn with a <xref:System.Windows.Media.Brushes.Black%2A> <xref:System.Windows.Media.Pen>. The <xref:System.Windows.Media.GeometryDrawing> is displayed using an <xref:System.Windows.Media.ImageDrawing> and an <xref:System.Windows.Controls.Image> element.
|
|
|
|
[!code-csharp[DrawingMiscSnippets_snip#GeometryDrawingExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/DrawingMiscSnippets_snip/CSharp/GeometryDrawingExample.cs#geometrydrawingexamplewholepage)]
|
|
[!code-xaml[DrawingMiscSnippets_snip#GeometryDrawingExampleWholePage](~/samples/snippets/xaml/VS_Snippets_Wpf/DrawingMiscSnippets_snip/XAML/GeometryDrawingExample.xaml#geometrydrawingexamplewholepage)]
|
|
|
|
The following illustration shows the resulting <xref:System.Windows.Media.GeometryDrawing>.
|
|
|
|

|
|
|
|
To create more complex drawings, you can combine multiple drawing objects into a single composite drawing using a <xref:System.Windows.Media.DrawingGroup>.
|
|
|
|
## See also
|
|
|
|
- <xref:System.Windows.Media.DrawingGroup>
|
|
- [Drawing Objects Overview](drawing-objects-overview.md)
|
|
- [Geometry Overview](geometry-overview.md)
|
|
- [Create a Composite Drawing](how-to-create-a-composite-drawing.md)
|