Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
508 lines (468 sloc) 31.1 KB
<Type Name="ListBoxItem" FullName="System.Windows.Controls.ListBoxItem">
<TypeSignature Language="C#" Value="public class ListBoxItem : System.Windows.Controls.ContentControl" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi ListBoxItem extends System.Windows.Controls.ContentControl" />
<TypeSignature Language="DocId" Value="T:System.Windows.Controls.ListBoxItem" />
<TypeSignature Language="VB.NET" Value="Public Class ListBoxItem&#xA;Inherits ContentControl" />
<TypeSignature Language="C++ CLI" Value="public ref class ListBoxItem : System::Windows::Controls::ContentControl" />
<TypeSignature Language="F#" Value="type ListBoxItem = class&#xA; inherit ContentControl" />
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Windows.Controls.ContentControl</BaseTypeName>
</Base>
<Interfaces />
<Attributes>
<Attribute>
<AttributeName>System.ComponentModel.DefaultEvent("Selected")</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>Represents a selectable item in a <see cref="T:System.Windows.Controls.ListBox" />.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
A <xref:System.Windows.Controls.ListBox> contains a collection of <xref:System.Windows.Controls.ListBoxItem> objects. To select a <xref:System.Windows.Controls.ListBoxItem> in a <xref:System.Windows.Controls.ListBox>, set the <xref:System.Windows.Controls.ListBoxItem.IsSelected%2A> property to `true`.
Bind a <xref:System.Windows.Controls.ListBoxItem> to data by binding the <xref:System.Windows.Controls.ItemsControl.ItemsSource%2A> property of a <xref:System.Windows.Controls.ListBox> to a data source. For more information, see [How to: Bind a ListBox to Data](~/docs/framework/wpf/controls/how-to-bind-a-listbox-to-data.md). You can customize the appearance of a <xref:System.Windows.Controls.ListBoxItem> by setting the <xref:System.Windows.Controls.ItemsControl.ItemTemplate%2A> property of a <xref:System.Windows.Controls.ListBox> to a <xref:System.Windows.DataTemplate>. For more information, see [Data Templating Overview](~/docs/framework/wpf/data/data-templating-overview.md).
By default, the <xref:System.Windows.FrameworkElement.HorizontalAlignment%2A> of a <xref:System.Windows.Controls.ListBoxItem> 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.ListBoxItem> through a <xref:System.Windows.Controls.StackPanel>, the panel's default is applied and the item is centered.
A <xref:System.Windows.Controls.ListBoxItem> 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 ListBoxItem Control
To apply the same property settings to multiple <xref:System.Windows.Controls.ListBoxItem> 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.ListBoxItem>, see [ListBox Styles and Templates](~/docs/framework/wpf/controls/listbox-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)]
## Examples
The following example shows how to create a <xref:System.Windows.Controls.ListBox> that contains <xref:System.Windows.Controls.ListBoxItem> elements.
[!code-xaml[ListBoxEvent#1](~/samples/snippets/csharp/VS_Snippets_Wpf/ListBoxEvent/CSharp/Pane1.xaml#1)]
]]></format>
</remarks>
</Docs>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public ListBoxItem ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.Controls.ListBoxItem.#ctor" />
<MemberSignature Language="VB.NET" Value="Public Sub New ()" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; ListBoxItem();" />
<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.ListBoxItem" /> class.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="IsSelected">
<MemberSignature Language="C#" Value="public bool IsSelected { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance bool IsSelected" />
<MemberSignature Language="DocId" Value="P:System.Windows.Controls.ListBoxItem.IsSelected" />
<MemberSignature Language="VB.NET" Value="Public Property IsSelected As Boolean" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; property bool IsSelected { bool get(); void set(bool value); };" />
<MemberSignature Language="F#" Value="member this.IsSelected : bool with get, set" Usage="System.Windows.Controls.ListBoxItem.IsSelected" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>System.ComponentModel.Bindable(true)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.ComponentModel.Category("Appearance")</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets a value that indicates whether a <see cref="T:System.Windows.Controls.ListBoxItem" /> is selected.</summary>
<value>
<see langword="true" /> if the item is selected; otherwise, <see langword="false" />. The default is <see langword="false" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
To select a <xref:System.Windows.Controls.ListBoxItem> in a <xref:System.Windows.Controls.ListBox>, set this property to `true`.
<a name="dependencyPropertyInfo_IsSelected"></a>
## Dependency Property Information
|||
|-|-|
|Identifier field|<xref:System.Windows.Controls.ListBoxItem.IsSelectedProperty>|
|Metadata properties set to `true`|<xref:System.Windows.FrameworkPropertyMetadata.BindsTwoWayByDefault%2A>|
## Examples
The following example shows how to set a list box item to be selected when the list box is created.
[!code-xaml[ListBox_snip#ListBoxItemsIsSelected1](~/samples/snippets/csharp/VS_Snippets_Wpf/ListBox_snip/CSharp/Window1.xaml#listboxitemsisselected1)]
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="IsSelectedProperty">
<MemberSignature Language="C#" Value="public static readonly System.Windows.DependencyProperty IsSelectedProperty;" />
<MemberSignature Language="ILAsm" Value=".field public static initonly class System.Windows.DependencyProperty IsSelectedProperty" />
<MemberSignature Language="DocId" Value="F:System.Windows.Controls.ListBoxItem.IsSelectedProperty" />
<MemberSignature Language="VB.NET" Value="Public Shared ReadOnly IsSelectedProperty As DependencyProperty " />
<MemberSignature Language="C++ CLI" Value="public: static initonly System::Windows::DependencyProperty ^ IsSelectedProperty;" />
<MemberSignature Language="F#" Value=" staticval mutable IsSelectedProperty : System.Windows.DependencyProperty" Usage="System.Windows.Controls.ListBoxItem.IsSelectedProperty" />
<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.ListBoxItem.IsSelected" /> dependency property.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="OnCreateAutomationPeer">
<MemberSignature Language="C#" Value="protected override System.Windows.Automation.Peers.AutomationPeer OnCreateAutomationPeer ();" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig virtual instance class System.Windows.Automation.Peers.AutomationPeer OnCreateAutomationPeer() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.Controls.ListBoxItem.OnCreateAutomationPeer" />
<MemberSignature Language="VB.NET" Value="Protected Overrides Function OnCreateAutomationPeer () As AutomationPeer" />
<MemberSignature Language="C++ CLI" Value="protected:&#xA; override System::Windows::Automation::Peers::AutomationPeer ^ OnCreateAutomationPeer();" />
<MemberSignature Language="F#" Value="override this.OnCreateAutomationPeer : unit -&gt; System.Windows.Automation.Peers.AutomationPeer" Usage="listBoxItem.OnCreateAutomationPeer " />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Windows.Automation.Peers.AutomationPeer</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Provides an appropriate <see cref="T:System.Windows.Automation.Peers.ListBoxItemAutomationPeer" /> implementation for this control, as part of the [!INCLUDE[TLA2#tla_winclient](~/includes/tla2sharptla-winclient-md.md)] automation infrastructure.</summary>
<returns>The type-specific <see cref="T:System.Windows.Automation.Peers.AutomationPeer" /> implementation.</returns>
<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.ListBoxItem.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="listBoxItem.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">The event data.</param>
<summary>Called when the mouse enters a <see cref="T:System.Windows.Controls.ListBoxItem" />.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="OnMouseLeave">
<MemberSignature Language="C#" Value="protected override void OnMouseLeave (System.Windows.Input.MouseEventArgs e);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig virtual instance void OnMouseLeave(class System.Windows.Input.MouseEventArgs e) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.Controls.ListBoxItem.OnMouseLeave(System.Windows.Input.MouseEventArgs)" />
<MemberSignature Language="VB.NET" Value="Protected Overrides Sub OnMouseLeave (e As MouseEventArgs)" />
<MemberSignature Language="C++ CLI" Value="protected:&#xA; override void OnMouseLeave(System::Windows::Input::MouseEventArgs ^ e);" />
<MemberSignature Language="F#" Value="override this.OnMouseLeave : System.Windows.Input.MouseEventArgs -&gt; unit" Usage="listBoxItem.OnMouseLeave 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">The event data.</param>
<summary>Called when the mouse leaves a <see cref="T:System.Windows.Controls.ListBoxItem" />.</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.ListBoxItem.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="listBoxItem.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">The event data.</param>
<summary>Called when the user presses the right mouse button over the <see cref="T:System.Windows.Controls.ListBoxItem" />.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="OnMouseRightButtonDown">
<MemberSignature Language="C#" Value="protected override void OnMouseRightButtonDown (System.Windows.Input.MouseButtonEventArgs e);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig virtual instance void OnMouseRightButtonDown(class System.Windows.Input.MouseButtonEventArgs e) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.Controls.ListBoxItem.OnMouseRightButtonDown(System.Windows.Input.MouseButtonEventArgs)" />
<MemberSignature Language="VB.NET" Value="Protected Overrides Sub OnMouseRightButtonDown (e As MouseButtonEventArgs)" />
<MemberSignature Language="C++ CLI" Value="protected:&#xA; override void OnMouseRightButtonDown(System::Windows::Input::MouseButtonEventArgs ^ e);" />
<MemberSignature Language="F#" Value="override this.OnMouseRightButtonDown : System.Windows.Input.MouseButtonEventArgs -&gt; unit" Usage="listBoxItem.OnMouseRightButtonDown 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">The event data.</param>
<summary>Called when the user presses the right mouse button over a <see cref="T:System.Windows.Controls.ListBoxItem" />.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="OnSelected">
<MemberSignature Language="C#" Value="protected virtual void OnSelected (System.Windows.RoutedEventArgs e);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig newslot virtual instance void OnSelected(class System.Windows.RoutedEventArgs e) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.Controls.ListBoxItem.OnSelected(System.Windows.RoutedEventArgs)" />
<MemberSignature Language="VB.NET" Value="Protected Overridable Sub OnSelected (e As RoutedEventArgs)" />
<MemberSignature Language="C++ CLI" Value="protected:&#xA; virtual void OnSelected(System::Windows::RoutedEventArgs ^ e);" />
<MemberSignature Language="F#" Value="abstract member OnSelected : System.Windows.RoutedEventArgs -&gt; unit&#xA;override this.OnSelected : System.Windows.RoutedEventArgs -&gt; unit" Usage="listBoxItem.OnSelected e" />
<MemberType>Method</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>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="e" Type="System.Windows.RoutedEventArgs" />
</Parameters>
<Docs>
<param name="e">The event data.</param>
<summary>Called when the <see cref="T:System.Windows.Controls.ListBoxItem" /> is selected in a <see cref="T:System.Windows.Controls.ListBox" />.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This method is called when the <xref:System.Windows.Controls.ListBoxItem.IsSelected%2A> property changes to `true`.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="OnUnselected">
<MemberSignature Language="C#" Value="protected virtual void OnUnselected (System.Windows.RoutedEventArgs e);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig newslot virtual instance void OnUnselected(class System.Windows.RoutedEventArgs e) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.Controls.ListBoxItem.OnUnselected(System.Windows.RoutedEventArgs)" />
<MemberSignature Language="VB.NET" Value="Protected Overridable Sub OnUnselected (e As RoutedEventArgs)" />
<MemberSignature Language="C++ CLI" Value="protected:&#xA; virtual void OnUnselected(System::Windows::RoutedEventArgs ^ e);" />
<MemberSignature Language="F#" Value="abstract member OnUnselected : System.Windows.RoutedEventArgs -&gt; unit&#xA;override this.OnUnselected : System.Windows.RoutedEventArgs -&gt; unit" Usage="listBoxItem.OnUnselected e" />
<MemberType>Method</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>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="e" Type="System.Windows.RoutedEventArgs" />
</Parameters>
<Docs>
<param name="e">The event data.</param>
<summary>Called when the <see cref="T:System.Windows.Controls.ListBoxItem" /> is unselected in a <see cref="T:System.Windows.Controls.ListBox" />.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This method is called when the <xref:System.Windows.Controls.ListBoxItem.IsSelected%2A> property changes to `false`.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="OnVisualParentChanged">
<MemberSignature Language="C#" Value="protected internal override void OnVisualParentChanged (System.Windows.DependencyObject oldParent);" />
<MemberSignature Language="ILAsm" Value=".method familyorassemblyhidebysig virtual instance void OnVisualParentChanged(class System.Windows.DependencyObject oldParent) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.Controls.ListBoxItem.OnVisualParentChanged(System.Windows.DependencyObject)" />
<MemberSignature Language="VB.NET" Value="Protected Friend Overrides Sub OnVisualParentChanged (oldParent As DependencyObject)" />
<MemberSignature Language="C++ CLI" Value="protected public:&#xA; override void OnVisualParentChanged(System::Windows::DependencyObject ^ oldParent);" />
<MemberSignature Language="F#" Value="override this.OnVisualParentChanged : System.Windows.DependencyObject -&gt; unit" Usage="listBoxItem.OnVisualParentChanged oldParent" />
<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="oldParent" Type="System.Windows.DependencyObject" />
</Parameters>
<Docs>
<param name="oldParent">The previous <see cref="P:System.Windows.FrameworkElement.Parent" /> property of the <see cref="T:System.Windows.Controls.ListBoxItem" />.</param>
<summary>Called when the visual parent of a list box item changes.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="Selected">
<MemberSignature Language="C#" Value="public event System.Windows.RoutedEventHandler Selected;" />
<MemberSignature Language="ILAsm" Value=".event class System.Windows.RoutedEventHandler Selected" />
<MemberSignature Language="DocId" Value="E:System.Windows.Controls.ListBoxItem.Selected" />
<MemberSignature Language="VB.NET" Value="Public Custom Event Selected As RoutedEventHandler " />
<MemberSignature Language="C++ CLI" Value="public:&#xA; event System::Windows::RoutedEventHandler ^ Selected;" />
<MemberSignature Language="F#" Value="member this.Selected : System.Windows.RoutedEventHandler " Usage="member this.Selected : System.Windows.RoutedEventHandler " />
<MemberType>Event</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Windows.RoutedEventHandler</ReturnType>
</ReturnValue>
<Docs>
<summary>Occurs when a <see cref="T:System.Windows.Controls.ListBoxItem" /> is selected.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
To know when the selection in a <xref:System.Windows.Controls.ListBox> changes, listen for the <xref:System.Windows.Controls.Primitives.Selector.SelectionChanged> event.
<a name="routedEventInfo_Selected"></a>
## Routed Event Information
|||
|-|-|
|Identifier field|<xref:System.Windows.Controls.ListBoxItem.SelectedEvent>|
|Routing strategy|Bubbling|
|Delegate|<xref:System.Windows.RoutedEventHandler>|
## Examples
The following example shows how to subscribe to and handle this event.
[!code-xaml[ListBox_snip#ListBoxItemsEvents](~/samples/snippets/csharp/VS_Snippets_Wpf/ListBox_snip/CSharp/Window1.xaml#listboxitemsevents)]
[!code-csharp[ListBox_snip#ListBoxItemsEventSelected](~/samples/snippets/csharp/VS_Snippets_Wpf/ListBox_snip/CSharp/Window1.xaml.cs#listboxitemseventselected)]
[!code-vb[ListBox_snip#ListBoxItemsEventSelected](~/samples/snippets/visualbasic/VS_Snippets_Wpf/ListBox_snip/visualbasic/window1.xaml.vb#listboxitemseventselected)]
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="SelectedEvent">
<MemberSignature Language="C#" Value="public static readonly System.Windows.RoutedEvent SelectedEvent;" />
<MemberSignature Language="ILAsm" Value=".field public static initonly class System.Windows.RoutedEvent SelectedEvent" />
<MemberSignature Language="DocId" Value="F:System.Windows.Controls.ListBoxItem.SelectedEvent" />
<MemberSignature Language="VB.NET" Value="Public Shared ReadOnly SelectedEvent As RoutedEvent " />
<MemberSignature Language="C++ CLI" Value="public: static initonly System::Windows::RoutedEvent ^ SelectedEvent;" />
<MemberSignature Language="F#" Value=" staticval mutable SelectedEvent : System.Windows.RoutedEvent" Usage="System.Windows.Controls.ListBoxItem.SelectedEvent" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Windows.RoutedEvent</ReturnType>
</ReturnValue>
<Docs>
<summary>Identifies the <see cref="E:System.Windows.Controls.ListBoxItem.Selected" /> routed event.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="Unselected">
<MemberSignature Language="C#" Value="public event System.Windows.RoutedEventHandler Unselected;" />
<MemberSignature Language="ILAsm" Value=".event class System.Windows.RoutedEventHandler Unselected" />
<MemberSignature Language="DocId" Value="E:System.Windows.Controls.ListBoxItem.Unselected" />
<MemberSignature Language="VB.NET" Value="Public Custom Event Unselected As RoutedEventHandler " />
<MemberSignature Language="C++ CLI" Value="public:&#xA; event System::Windows::RoutedEventHandler ^ Unselected;" />
<MemberSignature Language="F#" Value="member this.Unselected : System.Windows.RoutedEventHandler " Usage="member this.Unselected : System.Windows.RoutedEventHandler " />
<MemberType>Event</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Windows.RoutedEventHandler</ReturnType>
</ReturnValue>
<Docs>
<summary>Occurs when a <see cref="T:System.Windows.Controls.ListBoxItem" /> is unselected.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
To know when the selection in a <xref:System.Windows.Controls.ListBox> changes, listen for the <xref:System.Windows.Controls.Primitives.Selector.SelectionChanged> event.
<a name="routedEventInfo_Unselected"></a>
## Routed Event Information
|||
|-|-|
|Identifier field|<xref:System.Windows.Controls.ListBoxItem.UnselectedEvent>|
|Routing strategy|Bubbling|
|Delegate|<xref:System.Windows.RoutedEventHandler>|
## Examples
The following examples show how to subscribe to and handle this event.
[!code-xaml[ListBox_snip#ListBoxItemsEvents](~/samples/snippets/csharp/VS_Snippets_Wpf/ListBox_snip/CSharp/Window1.xaml#listboxitemsevents)]
[!code-csharp[ListBox_snip#ListBoxItemsEventUnselected](~/samples/snippets/csharp/VS_Snippets_Wpf/ListBox_snip/CSharp/Window1.xaml.cs#listboxitemseventunselected)]
[!code-vb[ListBox_snip#ListBoxItemsEventUnselected](~/samples/snippets/visualbasic/VS_Snippets_Wpf/ListBox_snip/visualbasic/window1.xaml.vb#listboxitemseventunselected)]
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="UnselectedEvent">
<MemberSignature Language="C#" Value="public static readonly System.Windows.RoutedEvent UnselectedEvent;" />
<MemberSignature Language="ILAsm" Value=".field public static initonly class System.Windows.RoutedEvent UnselectedEvent" />
<MemberSignature Language="DocId" Value="F:System.Windows.Controls.ListBoxItem.UnselectedEvent" />
<MemberSignature Language="VB.NET" Value="Public Shared ReadOnly UnselectedEvent As RoutedEvent " />
<MemberSignature Language="C++ CLI" Value="public: static initonly System::Windows::RoutedEvent ^ UnselectedEvent;" />
<MemberSignature Language="F#" Value=" staticval mutable UnselectedEvent : System.Windows.RoutedEvent" Usage="System.Windows.Controls.ListBoxItem.UnselectedEvent" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Windows.RoutedEvent</ReturnType>
</ReturnValue>
<Docs>
<summary>Identifies the <see cref="E:System.Windows.Controls.ListBoxItem.Unselected" /> routed event.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
</Members>
</Type>
You can’t perform that action at this time.