Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
266 lines (250 sloc) 17.1 KB
<Type Name="ComboBoxItem" FullName="System.Windows.Controls.ComboBoxItem">
<TypeSignature Language="C#" Value="public class ComboBoxItem : System.Windows.Controls.ListBoxItem" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi ComboBoxItem extends System.Windows.Controls.ListBoxItem" />
<TypeSignature Language="DocId" Value="T:System.Windows.Controls.ComboBoxItem" />
<TypeSignature Language="VB.NET" Value="Public Class ComboBoxItem&#xA;Inherits ListBoxItem" />
<TypeSignature Language="C++ CLI" Value="public ref class ComboBoxItem : System::Windows::Controls::ListBoxItem" />
<TypeSignature Language="F#" Value="type ComboBoxItem = class&#xA; inherit ListBoxItem" />
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Windows.Controls.ListBoxItem</BaseTypeName>
</Base>
<Interfaces />
<Attributes>
<Attribute>
<AttributeName>System.Windows.Localizability(System.Windows.LocalizationCategory.ComboBox)</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>Implements a selectable item inside a <see cref="T:System.Windows.Controls.ComboBox" />.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
> [!NOTE]
> By default, the <xref:System.Windows.FrameworkElement.HorizontalAlignment%2A> of a <xref:System.Windows.Controls.ComboBoxItem> is set to <xref:System.Windows.HorizontalAlignment.Stretch>. The default horizontal position of a <xref:System.Windows.Controls.StackPanel> is <xref:System.Windows.HorizontalAlignment.Center>. If you set the <xref:System.Windows.FrameworkElement.Width%2A> property of a <xref:System.Windows.Controls.ComboBoxItem> through a <xref:System.Windows.Controls.StackPanel>, the panel's default is applied and the item will be centered.
A <xref:System.Windows.Controls.ComboBoxItem> is a <xref:System.Windows.Controls.ContentControl>, which means that it can contain a single object of any type (such as a string, an image, or a panel). For more information, see the <xref:System.Windows.Controls.ContentControl> class.
## Customizing the ComboBoxItem Control
To apply the same property settings to multiple <xref:System.Windows.Controls.ComboBoxItem> controls, use the <xref:System.Windows.FrameworkElement.Style%2A> property. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information about creating a <xref:System.Windows.Controls.ControlTemplate>, see [Customizing the Appearance of an Existing Control by Creating a ControlTemplate](~/docs/framework/wpf/controls/customizing-the-appearance-of-an-existing-control.md). To see the parts and states that are specific to the <xref:System.Windows.Controls.ComboBoxItem>, see [ComboBox Styles and Templates](~/docs/framework/wpf/controls/combobox-styles-and-templates.md).
Dependency properties for this control might be set by the control's default style. If a property is set by a default style, the property might change from its default value when the control appears in the application. The default style is determined by which desktop theme is used when the application is running. For more information, see [Default WPF Themes](https://go.microsoft.com/fwlink/?LinkID=158252).
[!INCLUDE[setting-a-visual-property](~/includes/visual-property-note.md)]
]]></format>
</remarks>
<altmember cref="T:System.Windows.Controls.ComboBox" />
<related type="Article" href="https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms741921(v=vs.90)">ComboBoxItem Control Template</related>
</Docs>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public ComboBoxItem ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.Controls.ComboBoxItem.#ctor" />
<MemberSignature Language="VB.NET" Value="Public Sub New ()" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; ComboBoxItem();" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")</AttributeName>
</Attribute>
</Attributes>
<Parameters />
<Docs>
<summary>Initializes a new instance of the <see cref="T:System.Windows.Controls.ComboBoxItem" /> class</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="IsHighlighted">
<MemberSignature Language="C#" Value="public bool IsHighlighted { get; protected set; }" />
<MemberSignature Language="ILAsm" Value=".property instance bool IsHighlighted" />
<MemberSignature Language="DocId" Value="P:System.Windows.Controls.ComboBoxItem.IsHighlighted" />
<MemberSignature Language="VB.NET" Value="Public Property IsHighlighted As Boolean" />
<MemberSignature Language="C++ CLI" Value="public: property bool IsHighlighted { public:&#xA;bool get(); protected:&#xA; void set(bool value); };" />
<MemberSignature Language="F#" Value="member this.IsHighlighted : bool with get, set" Usage="System.Windows.Controls.ComboBoxItem.IsHighlighted" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets a value that indicates whether the item is highlighted.</summary>
<value>
<see langword="true" /> if a <see cref="T:System.Windows.Controls.ComboBoxItem" /> is highlighted; otherwise, <see langword="false" />. The default is <see langword="false" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This property can be used by styles that need a highlight to indicate selection.
Starting with the .NET Framework version 3.0 Service Pack 1, <xref:System.Windows.Controls.ComboBoxItem.IsHighlighted%2A> has a protected setter. To use this functionality, your application should target the .NET Framework version 3.5. For more information, see [Versions and Dependencies](~/docs/framework/migration-guide/versions-and-dependencies.md).
<a name="dependencyPropertyInfo_IsHighlighted"></a>
## Dependency Property Information
|||
|-|-|
|Identifier Field|<xref:System.Windows.Controls.ComboBoxItem.IsHighlightedProperty>|
|Metadata properties set to `true`|None|
## Examples
The following example changes the appearance of a <xref:System.Windows.Controls.ComboBoxItem> when <xref:System.Windows.Controls.ComboBoxItem.IsHighlighted%2A> is `true`.
[!code-xaml[ComboBoxSimple#1](~/samples/snippets/csharp/VS_Snippets_Wpf/ComboBoxSimple/CSharp/Pane1.xaml#1)]
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="IsHighlightedProperty">
<MemberSignature Language="C#" Value="public static readonly System.Windows.DependencyProperty IsHighlightedProperty;" />
<MemberSignature Language="ILAsm" Value=".field public static initonly class System.Windows.DependencyProperty IsHighlightedProperty" />
<MemberSignature Language="DocId" Value="F:System.Windows.Controls.ComboBoxItem.IsHighlightedProperty" />
<MemberSignature Language="VB.NET" Value="Public Shared ReadOnly IsHighlightedProperty As DependencyProperty " />
<MemberSignature Language="C++ CLI" Value="public: static initonly System::Windows::DependencyProperty ^ IsHighlightedProperty;" />
<MemberSignature Language="F#" Value=" staticval mutable IsHighlightedProperty : System.Windows.DependencyProperty" Usage="System.Windows.Controls.ComboBoxItem.IsHighlightedProperty" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Windows.DependencyProperty</ReturnType>
</ReturnValue>
<Docs>
<summary>Identifies the <see cref="P:System.Windows.Controls.ComboBoxItem.IsHighlighted" /> dependency property.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="OnContentChanged">
<MemberSignature Language="C#" Value="protected override void OnContentChanged (object oldContent, object newContent);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig virtual instance void OnContentChanged(object oldContent, object newContent) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.Controls.ComboBoxItem.OnContentChanged(System.Object,System.Object)" />
<MemberSignature Language="VB.NET" Value="Protected Overrides Sub OnContentChanged (oldContent As Object, newContent As Object)" />
<MemberSignature Language="C++ CLI" Value="protected:&#xA; override void OnContentChanged(System::Object ^ oldContent, System::Object ^ newContent);" />
<MemberSignature Language="F#" Value="override this.OnContentChanged : obj * obj -&gt; unit" Usage="comboBoxItem.OnContentChanged (oldContent, newContent)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="oldContent" Type="System.Object" />
<Parameter Name="newContent" Type="System.Object" />
</Parameters>
<Docs>
<param name="oldContent">Old content.</param>
<param name="newContent">New content.</param>
<summary>Called when the <see cref="P:System.Windows.Controls.ContentControl.Content" /> property changes.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="OnGotKeyboardFocus">
<MemberSignature Language="C#" Value="protected override void OnGotKeyboardFocus (System.Windows.Input.KeyboardFocusChangedEventArgs e);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig virtual instance void OnGotKeyboardFocus(class System.Windows.Input.KeyboardFocusChangedEventArgs e) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.Controls.ComboBoxItem.OnGotKeyboardFocus(System.Windows.Input.KeyboardFocusChangedEventArgs)" />
<MemberSignature Language="VB.NET" Value="Protected Overrides Sub OnGotKeyboardFocus (e As KeyboardFocusChangedEventArgs)" />
<MemberSignature Language="C++ CLI" Value="protected:&#xA; override void OnGotKeyboardFocus(System::Windows::Input::KeyboardFocusChangedEventArgs ^ e);" />
<MemberSignature Language="F#" Value="override this.OnGotKeyboardFocus : System.Windows.Input.KeyboardFocusChangedEventArgs -&gt; unit" Usage="comboBoxItem.OnGotKeyboardFocus e" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="e" Type="System.Windows.Input.KeyboardFocusChangedEventArgs" />
</Parameters>
<Docs>
<param name="e">Keyboard input event arguments.</param>
<summary>Announces that the keyboard is focused on this element.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="OnMouseEnter">
<MemberSignature Language="C#" Value="protected override void OnMouseEnter (System.Windows.Input.MouseEventArgs e);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig virtual instance void OnMouseEnter(class System.Windows.Input.MouseEventArgs e) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.Controls.ComboBoxItem.OnMouseEnter(System.Windows.Input.MouseEventArgs)" />
<MemberSignature Language="VB.NET" Value="Protected Overrides Sub OnMouseEnter (e As MouseEventArgs)" />
<MemberSignature Language="C++ CLI" Value="protected:&#xA; override void OnMouseEnter(System::Windows::Input::MouseEventArgs ^ e);" />
<MemberSignature Language="F#" Value="override this.OnMouseEnter : System.Windows.Input.MouseEventArgs -&gt; unit" Usage="comboBoxItem.OnMouseEnter e" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="e" Type="System.Windows.Input.MouseEventArgs" />
</Parameters>
<Docs>
<param name="e">Provides data for <see cref="T:System.Windows.Input.MouseEventArgs" />.</param>
<summary>Responds to a <see cref="E:System.Windows.UIElement.MouseEnter" /> event.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="OnMouseLeftButtonDown">
<MemberSignature Language="C#" Value="protected override void OnMouseLeftButtonDown (System.Windows.Input.MouseButtonEventArgs e);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig virtual instance void OnMouseLeftButtonDown(class System.Windows.Input.MouseButtonEventArgs e) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.Controls.ComboBoxItem.OnMouseLeftButtonDown(System.Windows.Input.MouseButtonEventArgs)" />
<MemberSignature Language="VB.NET" Value="Protected Overrides Sub OnMouseLeftButtonDown (e As MouseButtonEventArgs)" />
<MemberSignature Language="C++ CLI" Value="protected:&#xA; override void OnMouseLeftButtonDown(System::Windows::Input::MouseButtonEventArgs ^ e);" />
<MemberSignature Language="F#" Value="override this.OnMouseLeftButtonDown : System.Windows.Input.MouseButtonEventArgs -&gt; unit" Usage="comboBoxItem.OnMouseLeftButtonDown e" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="e" Type="System.Windows.Input.MouseButtonEventArgs" />
</Parameters>
<Docs>
<param name="e">Provides data for <see cref="T:System.Windows.Input.MouseButtonEventArgs" />.</param>
<summary>Responds to the <see cref="E:System.Windows.UIElement.MouseLeftButtonDown" /> event.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="OnMouseLeftButtonUp">
<MemberSignature Language="C#" Value="protected override void OnMouseLeftButtonUp (System.Windows.Input.MouseButtonEventArgs e);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig virtual instance void OnMouseLeftButtonUp(class System.Windows.Input.MouseButtonEventArgs e) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.Controls.ComboBoxItem.OnMouseLeftButtonUp(System.Windows.Input.MouseButtonEventArgs)" />
<MemberSignature Language="VB.NET" Value="Protected Overrides Sub OnMouseLeftButtonUp (e As MouseButtonEventArgs)" />
<MemberSignature Language="C++ CLI" Value="protected:&#xA; override void OnMouseLeftButtonUp(System::Windows::Input::MouseButtonEventArgs ^ e);" />
<MemberSignature Language="F#" Value="override this.OnMouseLeftButtonUp : System.Windows.Input.MouseButtonEventArgs -&gt; unit" Usage="comboBoxItem.OnMouseLeftButtonUp e" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="e" Type="System.Windows.Input.MouseButtonEventArgs" />
</Parameters>
<Docs>
<param name="e">Provides data for <see cref="T:System.Windows.Input.MouseButtonEventArgs" />.</param>
<summary>Responds to the <see cref="E:System.Windows.UIElement.MouseLeftButtonUp" /> event.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
</Members>
</Type>
You can’t perform that action at this time.