Skip to main content
.NET Framework Class Library
PanelIsItemsHost Property

Gets or sets a value that indicates that this Panel is a container for user interface (UI) items that are generated by an ItemsControl.  

Namespace:   System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
Syntax
<[%$TOPIC/ms605173_en-us_VS_110_3_0_0_0_0%](False)> _
Public Property IsItemsHost As [%$TOPIC/ms605173_en-us_VS_110_3_0_0_0_1%]
[[%$TOPIC/ms605173_en-us_VS_110_3_0_1_0_0%](false)]
public [%$TOPIC/ms605173_en-us_VS_110_3_0_1_0_1%] IsItemsHost { get; set; }
[[%$TOPIC/ms605173_en-us_VS_110_3_0_2_0_0%](false)]
public:
property [%$TOPIC/ms605173_en-us_VS_110_3_0_2_0_1%] IsItemsHost {
	[%$TOPIC/ms605173_en-us_VS_110_3_0_2_0_2%] get ();
	void set ([%$TOPIC/ms605173_en-us_VS_110_3_0_2_0_3%] value);
}
[<[%$TOPIC/ms605173_en-us_VS_110_3_0_3_0_0%](false)>]
member IsItemsHost : [%$TOPIC/ms605173_en-us_VS_110_3_0_3_0_1%] with get, set
function get IsItemsHost () : [%$TOPIC/ms605173_en-us_VS_110_3_0_4_0_0%] 
function set IsItemsHost (value : [%$TOPIC/ms605173_en-us_VS_110_3_0_4_0_1%])
<object IsItemsHost="[%$TOPIC/ms605173_en-us_VS_110_3_0_5_0_0%]" .../>

Property Value

Type: SystemBoolean
true if this instance of Panel is an items host; otherwise, false. The default value is false.
Dependency Property Information

Identifier field

IsItemsHostProperty

Metadata properties set to true

IsNotDataBindable

Remarks

You cannot bind data to this property.

Examples

The following example uses a ControlTemplate to create a horizontal ListBox. The horizontal StackPanel is specified within the ControlTemplate. The IsItemsHost property is set to true on the StackPanel, which indicates that the generated items should be placed in the panel. When you specify it this way, the ItemsPanel cannot be replaced by the user of the control without using a ControlTemplate. Therefore, do this only if you know that you do not want the panel to be replaced without the use of a template.

<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>

Alternatively, you can set the ItemsControlItemsPanel property. The following example sets the ItemsPanel in a Style of a ListBox.

<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>
Version Information

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1