TabControl.ContentTemplate Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the DataTemplate to apply to any TabItem that does not have a ContentTemplate or ContentTemplateSelector property defined.
public:
property System::Windows::DataTemplate ^ ContentTemplate { System::Windows::DataTemplate ^ get(); void set(System::Windows::DataTemplate ^ value); };
public System.Windows.DataTemplate ContentTemplate { get; set; }
member this.ContentTemplate : System.Windows.DataTemplate with get, set
Public Property ContentTemplate As DataTemplate
The DataTemplate to apply to any TabItem that does not have a ContentTemplate or ContentTemplateSelector property defined. The default is null
.
The following example creates two DataTemplate objects. The DataTemplate called contentTemplate
is assigned to the ContentTemplate of the TabControl and the DataTemplate called tabItemTemplate
is assigned to the ContentTemplate of the second TabItem. All TabItem objects contain the white rectangle defined in contentTemplate
, except the second TabItem, which has a gray rectangle, as defined in tabItemTemplate
.
<DataTemplate x:Key="contentTemplate">
<Grid>
<Rectangle Fill="White"/>
<ContentPresenter Content="{Binding}"/>
</Grid>
</DataTemplate>
<DataTemplate x:Key="tabItemTemplate">
<Grid>
<Rectangle Fill="Gray"/>
<ContentPresenter Content="{Binding}"/>
</Grid>
</DataTemplate>
<TabControl Width="250" Height="300"
ContentTemplate="{StaticResource contentTemplate}">
<TabItem Header="One">
<Ellipse Width="200" Height="200" Fill="#CABCAB"/>
</TabItem>
<TabItem Header="Two"
ContentTemplate="{StaticResource tabItemTemplate}">
<Ellipse Width="200" Height="200" Fill="#BADDF00D"/>
</TabItem>
<TabItem Header="Three">
<Ellipse Width="200" Height="200" Fill="#654321"/>
</TabItem>
<TabItem Header="Four">
<Ellipse Width="200" Height="200" Fill="#123456"/>
</TabItem>
<TabItem Header="Five">
<Ellipse Width="200" Height="200" Fill="#F11001"/>
</TabItem>
</TabControl>
<object ContentTemplate="{ResourceExtension TemplateResourceKey}"/>
ResourceExtension
One of the following: StaticResource
, or DynamicResource
. See XAML Resources.
TemplateResourceKey
The key that identifies the template being requested. The key refers to an existing resource in a ResourceDictionary.
Not
Property element syntax is technically possible, but not recommended. See Inline Styles and Templates.
Identifier field | ContentTemplateProperty |
Metadata properties set to true |
None |
Ürün | Sürümler |
---|---|
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |
.NET geri bildirimi
.NET, açık kaynak bir projedir. Geri bildirim sağlamak için bir bağlantı seçin: