Files
docs-desktop/dotnet-desktop-guide/framework/wpf/controls/how-to-create-an-expander-with-a-scrollviewer.md
Andy De George da363692ff Initial WPF content migrated (#17)
* 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
2020-09-04 09:46:28 -07:00

2.1 KiB

title, ms.date, helpviewer_keywords, ms.assetid
title ms.date helpviewer_keywords ms.assetid
How to: Create an Expander with a ScrollViewer 03/30/2017
controls [WPF], Expander
ScrollViewer control [WPF], with Expander control
Expander control [WPF], creating
controls [WPF], ScrollViewer
2ad124d2-2406-4157-aaf2-64e067298f01

How to: Create an Expander with a ScrollViewer

This example shows how to create an xref:System.Windows.Controls.Expander control that contains complex content, such as an image and text. The example also encloses the content of the xref:System.Windows.Controls.Expander in a xref:System.Windows.Controls.ScrollViewer control.

Example

The following example shows how to create an xref:System.Windows.Controls.Expander. The example uses a xref:System.Windows.Controls.Primitives.BulletDecorator control, which contains an image and text, in order to define the xref:System.Windows.Controls.HeaderedContentControl.Header%2A. A xref:System.Windows.Controls.ScrollViewer control provides a method for scrolling the expanded content.

Note that the example sets the xref:System.Windows.FrameworkElement.Height%2A property on the xref:System.Windows.Controls.ScrollViewer instead of on the content. If the xref:System.Windows.FrameworkElement.Height%2A is set on the content, the xref:System.Windows.Controls.ScrollViewer does not allow the user to scroll the content. The xref:System.Windows.FrameworkElement.Width%2A property is set on the xref:System.Windows.Controls.Expander control and this setting applies to the xref:System.Windows.Controls.HeaderedContentControl.Header%2A and the expanded content.

[!code-xamlExpanderRichContent#CreateExpander]

[!code-csharpExpanderRichContent#CreateExpanderCode]

See also