使用的ItemsSource时添加额外的项目, [英] Add extra items when using ItemsSource

查看:261
本文介绍了使用的ItemsSource时添加额外的项目,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我建设我有项目的TabControl 中,我要显示通过的ItemsSource 。我还需要的的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 MSDN )来实现:

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时添加额外的项目,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆