我正在使用TabControl來託管工作區,使用約翰史密斯的This amazing文章中概述的方法。我想知道是否有一種方法可以在標籤控件沒有標籤時添加內容,如圖像。排序默認或空行爲。我想要有應用程序徽標,或者可能是一些有用的箭頭a-la Chrome的第一次使用標籤。WPF空TabControl內容
編輯:這可能有點複雜。我在下面顯示的標準tabcontrol上試過乍得的解決方案。但是,我用於工作區的tabcontrol是由使用數據模板的內容控件呈現的,我無法使用他的解決方案。 HB的解決方案進行了一些改變。
<DataTemplate x:Key="WorkspacesTemplate">
<Grid>
<Image Name="image1" Stretch="Uniform" Source="/Affinity;component/Images/affinity_logo.png" Margin="20"/>
<TabControl IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding}"
ItemTemplate="{StaticResource ClosableTabItemTemplate}" Margin="4">
<TabControl.Style>
<Style TargetType="TabControl">
<Style.Triggers>
<DataTrigger Binding="{Binding Items.Count, RelativeSource={RelativeSource Self}}"
Value="0">
<Setter Property="Visibility" Value="Hidden" />
</DataTrigger>
</Style.Triggers>
</Style>
</TabControl.Style>
<TabControl.Template>
<ControlTemplate TargetType="TabControl">
<Grid Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Hidden" >
<StackPanel x:Name="HeaderPanel"
Orientation="Horizontal"
Panel.ZIndex ="1"
KeyboardNavigation.TabIndex="1"
Grid.Column="0"
Grid.Row="0"
Margin="2,2,2,0"
IsItemsHost="true"/>
</ScrollViewer>
<ContentPresenter x:Name="PART_SelectedContentHost" Grid.Row="1"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
Margin="{TemplateBinding Padding}"
ContentSource="SelectedContent"/>
</Grid>
</ControlTemplate>
</TabControl.Template>
</TabControl>
</Grid>
</DataTemplate>
這看起來很有希望,我在我的問題中添加了一些代碼,以顯示我的內容控件如何綁定到工作區集合。我正試圖讓他們現在都工作。 – Tyrsius
你的第一個解決方案結束了一些調整。 – Tyrsius