【发布时间】:2019-09-09 21:55:17
【问题描述】:
我需要在不同的 xaml 文件中使用 tabItem,但我不知道该怎么做。
我访问过 Tonny Bores 在这里回答:TabItem in a separate XAML
但是我不明白 tabData 是从哪里来的。
<TabItem x:Class="Hysolate.DisplayTab"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<TabItem.Resources>
<Style x:Key="TStyle"
TargetType="TextBlock">
<Setter Property="FontSize" Value="20" />
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</TabItem.Resources>
<TabItem.Header>
<TextBlock Style="{StaticResource TStyle}" Text="Tab No. 2"></TextBlock>
</TabItem.Header>
<Grid>
<TextBlock Text="Tab Data" />
</Grid>
</TabItem>
<!-- And I want to use it here (different xaml file):
<TabControl>
<tabdata:DisplayTab></tabdata:DisplayTab>
</TabControl>
-->
【问题讨论】: