* 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
1.5 KiB
title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
| title | ms.date | dev_langs | helpviewer_keywords | ms.assetid | ||||
|---|---|---|---|---|---|---|---|---|
| How to: Get a ListBoxItem | 03/30/2017 |
|
|
da877c6f-5fd8-40cb-8909-225cbfd99aa5 |
How to: Get a ListBoxItem
If you need to get a specific xref:System.Windows.Controls.ListBoxItem at a particular index in a xref:System.Windows.Controls.ListBox, you can use an xref:System.Windows.Controls.ItemContainerGenerator.
Example
The following example shows a xref:System.Windows.Controls.ListBox and its items.
[!code-xamlListBoxItems#1]
The following example shows how to retrieve the item by specifying the index of the item in the xref:System.Windows.Controls.ItemContainerGenerator.ContainerFromIndex%2A property of the xref:System.Windows.Controls.ItemContainerGenerator.
[!code-csharpListBoxItems#2] [!code-vbListBoxItems#2]
After you have retrieved the list box item, you can display the contents of the item, as shown in the following example.
[!code-csharpListBoxItems#3] [!code-vbListBoxItems#3]