ComboBoxItem Class
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace: http://schemas.microsoft.com/winfx/2006/xaml/presentation
'Declaration <LocalizabilityAttribute(LocalizationCategory.ComboBox)> _ Public Class ComboBoxItem Inherits ListBoxItem 'Usage Dim instance As ComboBoxItem
/** @attribute LocalizabilityAttribute(LocalizationCategory.ComboBox) */ public class ComboBoxItem extends ListBoxItem
LocalizabilityAttribute(LocalizationCategory.ComboBox) public class ComboBoxItem extends ListBoxItem
<ComboBoxItem> Content </ComboBoxItem>
Note: |
|---|
| By default the HorizontalAlignment of a ComboBoxItem is set to Stretch. The default horizontal position of a StackPanel is Center. If you set the Width property of a ComboBoxItem through a StackPanel, the panel's default is applied and the item will be centered. |
ContentModel: A ComboBoxItem is a ContentControl. For more information on the content model for ComboBoxItem, see ContentControl Content Model.
In the following example, the ComboBox contains three items. The control is in its collapsed position, which is the default state, until the user clicks the Button on the right side of the control.
<ComboBox Text="Is not open"> <ComboBoxItem MouseMove="OnHover" Name="cbi1">Item1</ComboBoxItem> <ComboBoxItem MouseMove="OnHover" Name="cbi2">Item2</ComboBoxItem> <ComboBoxItem MouseMove="OnHover" Name="cbi3">Item3</ComboBoxItem> </ComboBox>
Dim cbox As System.Windows.Controls.ComboBox Dim cboxitem As System.Windows.Controls.ComboBoxItem Dim cboxitem2 As System.Windows.Controls.ComboBoxItem Dim cboxitem3 As System.Windows.Controls.ComboBoxItem cbox = New ComboBox() cbox.Background = Brushes.LightBlue cboxitem = New ComboBoxItem() cboxitem.Content = "Created with Visual Basic." cbox.Items.Add(cboxitem) cboxitem2 = New ComboBoxItem() cboxitem2.Content = "Item 2" cbox.Items.Add(cboxitem2) cboxitem3 = New ComboBoxItem() cboxitem3.Content = "Item 3" cbox.Items.Add(cboxitem3) cv2.Children.Add(cbox)
For the complete sample, see ComboBox Sample.
System.Windows.Threading.DispatcherObject
System.Windows.DependencyObject
System.Windows.Media.Visual
System.Windows.UIElement
System.Windows.FrameworkElement
System.Windows.Controls.Control
System.Windows.Controls.ContentControl
System.Windows.Controls.ListBoxItem
System.Windows.Controls.ComboBoxItem
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.
Note: