mirror of
https://github.com/Stone-Red-Code/docs-desktop.git
synced 2026-09-09 23:43:28 +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.1 KiB
Markdown
32 lines
2.1 KiB
Markdown
---
|
|
title: "How to: Apply Stretch Properties to the Contents of a Viewbox"
|
|
ms.date: "03/30/2017"
|
|
dev_langs:
|
|
- "csharp"
|
|
- "vb"
|
|
helpviewer_keywords:
|
|
- "StretchDirection properties [WPF]"
|
|
- "Stretch properties [WPF]"
|
|
- "controls [WPF], Viewbox"
|
|
- "Viewbox control [WPF]"
|
|
ms.assetid: b9c22ef4-bce4-4300-9e0c-8260b7db83cc
|
|
---
|
|
# How to: Apply Stretch Properties to the Contents of a Viewbox
|
|
## Example
|
|
This example shows how to change the value of the <xref:System.Windows.Controls.Viewbox.StretchDirection%2A> and <xref:System.Windows.Controls.Viewbox.Stretch%2A> properties of a <xref:System.Windows.Controls.Viewbox>.
|
|
|
|
The first example uses [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] to define a <xref:System.Windows.Controls.Viewbox> element. It assigns a <xref:System.Windows.FrameworkElement.MaxWidth%2A> and <xref:System.Windows.FrameworkElement.MaxHeight%2A> of 400. The example nests an <xref:System.Windows.Controls.Image> element within the <xref:System.Windows.Controls.Viewbox>. <xref:System.Windows.Controls.Button> elements that correspond to the property values for the <xref:System.Windows.Controls.Viewbox.Stretch%2A> and <xref:System.Windows.Controls.StretchDirection> enumerations manipulate the stretching behavior of the nested <xref:System.Windows.Controls.Image>.
|
|
|
|
[!code-xaml[viewboxStretchLayoutSamp#1](~/samples/snippets/csharp/VS_Snippets_Wpf/viewboxStretchLayoutSamp/CSharp/Window1.xaml#1)]
|
|
|
|
The following code-behind file handles the <xref:System.Windows.Controls.Button> <xref:System.Windows.Controls.Primitives.ButtonBase.Click> events that the previous [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] example defines.
|
|
|
|
[!code-csharp[viewboxStretchLayoutSamp#2](~/samples/snippets/csharp/VS_Snippets_Wpf/viewboxStretchLayoutSamp/CSharp/Window1.xaml.cs#2)]
|
|
[!code-vb[viewboxStretchLayoutSamp#2](~/samples/snippets/visualbasic/VS_Snippets_Wpf/viewboxStretchLayoutSamp/VisualBasic/Window1.xaml.vb#2)]
|
|
|
|
## See also
|
|
|
|
- <xref:System.Windows.Controls.Viewbox>
|
|
- <xref:System.Windows.Media.Stretch>
|
|
- <xref:System.Windows.Controls.StretchDirection>
|