问题描述
在我建设我有项目的TabControl
中,我要显示通过的ItemsSource $ C $一系列标签C>。我还需要的
的TabControl
,不能位于的ItemsSource
开始有一些概述选项卡
In the project I am building I have a TabControl
in which I want to display a range of tabs through an ItemsSource
. I also need to have a few "overview" tabs at the beginning of the TabControl
, that cannot be located in ItemsSource
.
什么是实现这一目标的最佳途径,我能想到的唯一的办法就是让我的概述选项卡在我的XAML和公正手动通过代码添加标签项目而不是使用的ItemSource
这是去它的最好方式。
What is the best way to achieve this, the only way I can think of is to have my overview tabs in my XAML and to just add tab items manually through code instead of using ItemSource
is this the best way to go about it.
推荐答案
您可以使用 CompositeCollection
()来实现:
You can use CompositeCollection
(MSDN) to accomplish this:
<Window.Resources>
<CollectionViewSource x:Key="ExistingTabs" Source="{Binding ExistingTabs}"/>
</Window.Resources>
<TabControl>
<TabControl.ItemsSource>
<CompositeCollection>
<TabItem>SpecialItem</TabItem>
<CollectionContainer Collection="{Binding Source={StaticResource ExistingTabs}}"/>
</CompositeCollection>
</TabControl.ItemsSource>
</TabControl>
这篇关于使用的ItemsSource时添加额外的项目,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!