* 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
2.1 KiB
title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
| title | ms.date | dev_langs | helpviewer_keywords | ms.assetid | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| How to: Apply Stretch Properties to the Contents of a Viewbox | 03/30/2017 |
|
|
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 [!INCLUDETLA#tla_xaml] 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-xamlviewboxStretchLayoutSamp#1]
The following code-behind file handles the xref:System.Windows.Controls.Button xref:System.Windows.Controls.Primitives.ButtonBase.Click events that the previous [!INCLUDETLA2#tla_xaml] example defines.
[!code-csharpviewboxStretchLayoutSamp#2] [!code-vbviewboxStretchLayoutSamp#2]