정보
요청한 주제가 아래에 표시됩니다. 그러나 이 주제는 이 라이브러리에 포함되지 않습니다.
이 항목은 아직 평가되지 않았습니다.- 이 항목 평가

ListBox 클래스

Control that implements a list of selectable items.

네임스페이스: System.Windows.Controls
어셈블리: PresentationFramework(presentationframework.dll)
XML 네임스페이스:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

[StyleTypedPropertyAttribute(Property="ItemContainerStyle", StyleTargetType=typeof(ListBoxItem))] 
[LocalizabilityAttribute(LocalizationCategory.ListBox)] 
public class ListBox : Selector
/** @attribute StyleTypedPropertyAttribute(Property="ItemContainerStyle", StyleTargetType=System.Windows.Controls.ListBoxItem) */ 
/** @attribute LocalizabilityAttribute(LocalizationCategory.ListBox) */ 
public class ListBox extends Selector
StyleTypedPropertyAttribute(Property="ItemContainerStyle", StyleTargetType=System.Windows.Controls.ListBoxItem) 
LocalizabilityAttribute(LocalizationCategory.ListBox) 
public class ListBox extends Selector
<ListBox>
  Items
</ListBox>

ListBox controls are often used with data styling. See Data Templates Overview for a discussion of data styling.

ContentModel: A ListBox is an ItemsControl. For more information on the content model for ListBox, see ItemsControl Content Model.

This example shows how to create a ListBox using the Extensible Application Markup Language (XAML) and implement event handlers in C# or Microsoft Visual Basic to handle selection changes.

The ListBox in the following XAML example contains multiple list items. When the user selects one of the items, the event handler displays the name of the selected item in the TextBox.

<TextBox Name="tb" Width="140" Height="30"></TextBox>   
<ListBox Name="lb" Width="100" Height="55" SelectionChanged="PrintText" SelectionMode="Single">
      <ListBoxItem>Item 1</ListBoxItem>
      <ListBoxItem>Item 2</ListBoxItem>
      <ListBoxItem>Item 3</ListBoxItem>
      <ListBoxItem>Item 4</ListBoxItem>
      <ListBoxItem>Item 5</ListBoxItem>
      <ListBoxItem>Item 6</ListBoxItem>
      <ListBoxItem>Item 7</ListBoxItem>
      <ListBoxItem>Item 8</ListBoxItem>
      <ListBoxItem>Item 9</ListBoxItem>
      <ListBoxItem>Item 10</ListBoxItem>
</ListBox>

void PrintText(object sender, SelectionChangedEventArgs args)
{
  ListBoxItem lbi = ((sender as ListBox).SelectedItem as ListBoxItem);
  tb.Text = "   You selected " + lbi.Content.ToString() + ".";
}

For the complete sample see: List Box Sample.

System.Object
   System.Windows.Threading.DispatcherObject
     System.Windows.DependencyObject
       System.Windows.Media.Visual
         System.Windows.UIElement
           System.Windows.FrameworkElement
             System.Windows.Controls.Control
               System.Windows.Controls.ItemsControl
                 System.Windows.Controls.Primitives.Selector
                  System.Windows.Controls.ListBox
                     System.Windows.Controls.ListView
이 형식의 모든 public static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

Microsoft .NET Framework 3.0은 Windows Vista, Microsoft Windows XP SP2 및 Windows Server 2003 SP1에서 지원됩니다.

.NET Framework

3.0에서 지원
이 정보가 도움이 되었습니까?
(1500자 남음)
의견을 주셔서 감사합니다.

커뮤니티 추가 항목

표시:
© 2014 Microsoft. All rights reserved.