Panel.IsItemsHost 속성

정의

에 의해 ItemsControl생성된 UI(사용자 인터페이스) 항목에 대한 컨테이너임을 나타내는 Panel 값을 가져오거나 설정합니다.

public:
 property bool IsItemsHost { bool get(); void set(bool value); };
[System.ComponentModel.Bindable(false)]
public bool IsItemsHost { get; set; }
[<System.ComponentModel.Bindable(false)>]
member this.IsItemsHost : bool with get, set
Public Property IsItemsHost As Boolean

속성 값

Boolean

Panel의 이 인스턴스가 항목 호스트이면 true이고, 그렇지 않으면 false입니다. 기본값은 false입니다.

특성

예제

다음 예제에서는 한 ControlTemplate 가로 만들려면 ListBox합니다. 가로 StackPanel 내에 지정 된 ControlTemplate합니다. 합니다 IsItemsHost 속성이 trueStackPanel, 패널에서 생성된 된 항목을 배치 해야 함을 나타냅니다. 이러한 방식으로 지정 하는 경우는 ItemsPanel 를 사용 하지 않고 컨트롤의 사용자가 바꿀 수 없습니다는 ControlTemplate합니다. 따라서 수행이 패널 템플릿 사용 하지 않고 교체 하지 않을 경우에 합니다.

<Style TargetType="ListBox">
  <Setter Property="Template">
    <Setter.Value>
      <ControlTemplate TargetType="ListBox">
        <Border CornerRadius="5" Background="{TemplateBinding ListBox.Background}">
          <ScrollViewer HorizontalScrollBarVisibility="Auto">
            <StackPanel Orientation="Horizontal"
                       VerticalAlignment="Center"
                       HorizontalAlignment="Center"
                       IsItemsHost="True"/>
          </ScrollViewer>
        </Border>
      </ControlTemplate>
    </Setter.Value>
  </Setter>
</Style>

설정할 수 있습니다는 ItemsControl.ItemsPanel 속성입니다. 다음 예제에서는 합니다 ItemsPanelStyleListBox합니다.

<Grid.Resources>
  <Style TargetType="Separator">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type Separator}">
          <Border Width="2" Height="12" Margin="4" Background="Gray"/>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style TargetType="ListBox">
    <Setter Property="ItemsPanel">
      <Setter.Value>
        <ItemsPanelTemplate>
          <StackPanel Orientation="Horizontal"
                      VerticalAlignment="Center"
                      HorizontalAlignment="Center"/>
        </ItemsPanelTemplate>
      </Setter.Value>
    </Setter>
  </Style>
  
</Grid.Resources>

설명

이 속성에 데이터를 바인딩할 수 없습니다.

종속성 속성 정보

식별자 필드 IsItemsHostProperty
메타 데이터 속성 설정 true IsNotDataBindable

적용 대상

추가 정보