繁体   English   中英

使用viewmodel设置TabItem.Content不会显示数据模板中的视图

[英]setting TabItem.Content with viewmodel is not showing view from data template

在代码中,我在资源字典中有一个datatemplate

<DataTemplate DataType="{x:Type my:ContainerViewModel}"  x:Key="ContainerTemplate">
    <my:ContainerView/>
</DataTemplate>

此资源字典已添加到app.xaml中

<ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="ResourceDictionaries/DataTemplates.xaml" />
</ResourceDictionary.MergedDictionaries>

在代码中,我尝试使用视图模型设置选项卡项

var vm = new ContainerViewModel();
tabItem.Content = vm;

tabitem仅显示视图模型名称。 它没有查找显示视图的数据模板。 任何帮助表示赞赏

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM