Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WPF在tabcontrol中创建Tabitems的类型_Wpf_Tabcontrol_Tabitem - Fatal编程技术网

WPF在tabcontrol中创建Tabitems的类型

WPF在tabcontrol中创建Tabitems的类型,wpf,tabcontrol,tabitem,Wpf,Tabcontrol,Tabitem,我需要为我的tabcontrol创建Tabitems类型。 每个选项卡都有不同的内容和功能(Xaml和代码隐藏)。 例如,我想创建: *“客户详细信息”选项卡-包含客户详细信息字段。 *配置选项卡-用于配置应用程序的字段。 *统计选项卡-包含统计信息的表格和图形 有时,每个tabitem类型的两个或三个选项卡都会打开。 我不想一次又一次地复制粘贴同一客户选项卡或其他选项卡的TabItem.Content。 我想做一种标签 创建此类选项卡项类型的最佳方法是什么 通常我将我的选项卡ItemViewM

我需要为我的tabcontrol创建Tabitems类型。 每个选项卡都有不同的内容和功能(Xaml和代码隐藏)。 例如,我想创建: *“客户详细信息”选项卡-包含客户详细信息字段。 *配置选项卡-用于配置应用程序的字段。 *统计选项卡-包含统计信息的表格和图形

有时,每个tabitem类型的两个或三个选项卡都会打开。 我不想一次又一次地复制粘贴同一客户选项卡或其他选项卡的TabItem.Content。 我想做一种标签


创建此类选项卡项类型的最佳方法是什么

通常我将我的
选项卡ItemViewModels
存储在
父视图模型中,并使用
数据模板来定义每个视图模型的显示方式

<Window.Resources>
    <DataTemplate DataType="{x:Type local:CustomerDetailsViewModel}">
        <local:CustomerDetailsView />
    </DataTemplate>
    <DataTemplate DataType="{x:Type local:ConfigurationViewModel}">
        <local:ConfigurationView />
    </DataTemplate>
    <DataTemplate DataType="{x:Type local:StatisticsViewModel}">
        <local:StatisticsView />
    </DataTemplate>
</Window.Resources>

<TabControl ItemsSource="{Binding TabList}" SelectedItem="{Binding SelectedTab}" />