Files
docs-desktop/dotnet-desktop-guide/framework/wpf/data/how-to-bind-the-properties-of-two-controls.md
T
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

1.5 KiB

title, ms.date, helpviewer_keywords, ms.assetid
title ms.date helpviewer_keywords ms.assetid
How to: Bind the Properties of Two Controls 03/30/2017
data binding [WPF], binding properties of two controls
binding properties of two controls [WPF]
controls [WPF], binding properties of
06318fac-6afd-4c7d-a277-6d7ef50f47bc

How to: Bind the Properties of Two Controls

This example shows how to bind the property of one instantiated control to that of another using the xref:System.Windows.Data.Binding.ElementName%2A property.

Example

The following example shows how to bind the xref:System.Windows.Controls.Panel.Background%2A property of a xref:System.Windows.Controls.Canvas to the SelectedItem.Content property of a xref:System.Windows.Controls.ComboBox:

[!code-xamlBindDptoDp#1]

When this example is rendered it looks like the following:

Screenshot showing a combo box with the value green selected and a green square.

Note

The binding target property (in this example, the xref:System.Windows.Controls.Panel.Background%2A property) must be a dependency property. For more information, see Data Binding Overview.

See also