mirror of
https://github.com/Stone-Red-Code/docs-desktop.git
synced 2026-09-05 23:42:58 +02:00
* net-current-v30plus-md.md * net-current-v40plus-md.md * tla2sharptla-ui-md.md * tla2sharptla-uiautomation-md.md * tla2sharptla-winclient-md.md * tla2sharptla-xaml-md.md * tlasharptla-ui-md.md * tlasharptla-uiautomation-md.md * tlasharptla-winclient-md.md * tlasharptla-xaml-md.md * fix warnings
43 lines
3.2 KiB
Markdown
43 lines
3.2 KiB
Markdown
---
|
|
title: "How to: Create a Shape Using a StreamGeometry"
|
|
description: Learn how to create a Shape using a StreamGeometry.
|
|
ms.date: "03/30/2017"
|
|
ms.custom: devdivchpfy22
|
|
dev_langs:
|
|
- "csharp"
|
|
- "vb"
|
|
helpviewer_keywords:
|
|
- "graphics [WPF], shapes"
|
|
- "shapes [WPF], creating with StreamGeometry class"
|
|
ms.assetid: 08f7c8ce-074b-49cd-9aba-cc9592d4ee51
|
|
---
|
|
# How to: Create a Shape Using a StreamGeometry
|
|
<xref:System.Windows.Media.StreamGeometry> is lightweight alternative to <xref:System.Windows.Media.PathGeometry> for creating geometric shapes. Use a <xref:System.Windows.Media.StreamGeometry> when you need to describe a complex geometry but do not want the overhead of supporting data binding, animation, or modification. For example, because of its efficiency, the <xref:System.Windows.Media.StreamGeometry> class is a good choice for describing adorners.
|
|
|
|
## Create a triangular StreamGeometry
|
|
The following example uses attribute syntax to create a triangular <xref:System.Windows.Media.StreamGeometry> in XAML.
|
|
|
|
[!code-xaml[GeometriesMiscSnippets_snip#StreamGeometryTriangleExampleWholePage](~/samples/snippets/xaml/VS_Snippets_Wpf/GeometriesMiscSnippets_snip/XAML/StreamGeometryExample.xaml#streamgeometrytriangleexamplewholepage)]
|
|
|
|
For more information about <xref:System.Windows.Media.StreamGeometry> attribute syntax, see the [Path Markup Syntax](path-markup-syntax.md) page.
|
|
|
|
## Use a StreamGeometry to define a triangle
|
|
The next example uses a <xref:System.Windows.Media.StreamGeometry> to define a triangle in code. First, the example creates a <xref:System.Windows.Media.StreamGeometry>, then obtains a <xref:System.Windows.Media.StreamGeometryContext> and uses it to describe the triangle.
|
|
|
|
[!code-csharp[GeometriesMiscSnippets_procedural_snip#StreamGeometryTriangleExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/GeometriesMiscSnippets_procedural_snip/CSharp/StreamGeometryTriangleExample.cs#streamgeometrytriangleexamplewholepage)]
|
|
[!code-vb[GeometriesMiscSnippets_procedural_snip#StreamGeometryTriangleExampleWholePage](~/samples/snippets/visualbasic/VS_Snippets_Wpf/GeometriesMiscSnippets_procedural_snip/visualbasic/streamgeometrytriangleexample.vb#streamgeometrytriangleexamplewholepage)]
|
|
|
|
## Create a geometric shape in code
|
|
The next example creates a method that uses a <xref:System.Windows.Media.StreamGeometry> and <xref:System.Windows.Media.StreamGeometryContext> to define a geometric shape based on specified parameters.
|
|
|
|
[!code-csharp[GeometriesMiscSnippets_procedural_snip#StreamGeometryExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/GeometriesMiscSnippets_procedural_snip/CSharp/StreamGeometryExample.cs#streamgeometryexamplewholepage)]
|
|
[!code-vb[GeometriesMiscSnippets_procedural_snip#StreamGeometryExampleWholePage](~/samples/snippets/visualbasic/VS_Snippets_Wpf/GeometriesMiscSnippets_procedural_snip/visualbasic/streamgeometryexample.vb#streamgeometryexamplewholepage)]
|
|
|
|
## See also
|
|
|
|
- <xref:System.Windows.Media.PathGeometry>
|
|
- <xref:System.Windows.Media.StreamGeometry>
|
|
- <xref:System.Windows.Media.StreamGeometryContext>
|
|
- [Create a Shape by Using a PathGeometry](how-to-create-a-shape-by-using-a-pathgeometry.md)
|
|
- [Geometry Overview](geometry-overview.md)
|