Files
docs-desktop/dotnet-desktop-guide/framework/wpf/controls/how-to-apply-stretch-properties-to-the-contents-of-a-viewbox.md
T
Andy (Steve) De George be103da07e Replace various WPF include files with content (#1335)
* 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
2022-03-16 12:14:11 -04:00

2.0 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
csharp
vb
StretchDirection properties [WPF]
Stretch properties [WPF]
controls [WPF], Viewbox
Viewbox control [WPF]
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 Extensible Application Markup Language (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 XAML example defines.

[!code-csharpviewboxStretchLayoutSamp#2] [!code-vbviewboxStretchLayoutSamp#2]

See also