Y
Size: a a a
Y
Sf
Y
Sf
AS
\
\
\
Y
\
А
using assembly PresentationCore
using assembly PresentationFramework
using assembly WindowsBase
using assembly System.Windows.Forms
[xml]$xaml = @"
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WPF Tab Control ItemTemplate ContentTemplate Example" Height="350" Width="525">
<Grid>
<Grid.Resources>
<DataTemplate x:Key="CustomHeaderTemplate">
<Label Background="Yellow" Content="{Binding ID}" />
</DataTemplate>
<DataTemplate x:Key="CustomItemTemplate">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding NickName}" />
<TextBlock Grid.Column="1" Text="{Binding Breed}" />
</Grid>
</DataTemplate>
</Grid.Resources>
<TabControl x:Name="TabControl1"
Margin="10"
ItemTemplate="{StaticResource CustomHeaderTemplate}"
ContentTemplate="{StaticResource CustomItemTemplate}">
</TabControl>
</Grid>
</Window>
"@
class Cats
{
[String]$ID
[String]$NickName
[String]$Breed
}
$global:form = [Windows.Markup.XamlReader]::Load([System.Xml.XmlNodeReader]::new($xaml))
$cats = New-Object System.Collections.Generic.List[Cats]
$cats.Add((New-Object Cats -Property @{ ID = 1; NickName = "Snowball"; Breed = "Abyssinian Cat" }))
$cats.Add((New-Object Cats -Property @{ ID = 2; NickName = "Grampy"; Breed = "Birman Cat Breed" }))
$tabControl = $form.FindName("TabControl1")
$tabControl.ItemsSource = $cats
$form.ShowDialog() | Out-Null
V
V
V