Files
docs-desktop/dotnet-desktop-guide/framework/wpf/controls/how-to-bind-a-listbox-to-data.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.3 KiB

title, ms.date, helpviewer_keywords, ms.assetid
title ms.date helpviewer_keywords ms.assetid
How to: Bind a ListBox to Data 03/30/2017
ListBox controls [WPF], binding data to
data binding [WPF], ListBox control
binding data [WPF], to ListBox control
de93a907-709a-44a7-84bf-578b846a3d8b

How to: Bind a ListBox to Data

An application developer can create xref:System.Windows.Controls.ListBox controls without specifying the contents of each xref:System.Windows.Controls.ListBoxItem separately. You can use data binding to bind data to the individual items.

The following example shows how to create a xref:System.Windows.Controls.ListBox that populates the xref:System.Windows.Controls.ListBoxItem elements by data binding to a data source called Colors. In this case it is not necessary to use xref:System.Windows.Controls.ListBoxItem tags to specify the content of each item.

Example

[!code-xamlListBoxEvent#7]
[!code-xamlListBoxEvent#3]

See also