我有:
<DataTemplate DataType="{x:Type svgEdit:UserControlSvgEditModel}">
<svgEdit:UserControlSvgEdit />
</DataTemplate>
我想以编程的方式获取类型: svgEdit:UserControlSvgEdit
我的操作:
// Here the obj Type is the key to the resource, it works but
var key = new System.Windows.DataTemplateKey(obj.GetType());
var dataTemplate = (DataTemplate)DockSite.FindResource(key);
// I don't know how to get the DataTemplate associated type ????
var tc = dataTemplate.Template as TemplateContent;
但是我找不到如何检索相关的类型?
注意:我需要以编程方式实例化模板内容并将其传递给DockSite(停靠管理器)。