本文整理汇总了C#中DataTemplate.Seal方法的典型用法代码示例。如果您正苦于以下问题:C# DataTemplate.Seal方法的具体用法?C# DataTemplate.Seal怎么用?C# DataTemplate.Seal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataTemplate
的用法示例。
在下文中一共展示了DataTemplate.Seal方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateFallbackViewTemplate
internal static DataTemplate CreateFallbackViewTemplate(string errorText) {
var factory = new FrameworkElementFactory(typeof(FallbackView));
factory.SetValue(FallbackView.TextProperty, errorText);
var res = new DataTemplate() { VisualTree = factory };
res.Seal();
return res;
}
示例2: CreateViewTemplate
public static DataTemplate CreateViewTemplate(this IViewLocator viewLocator, Type viewType) {
Verify(viewLocator);
if(viewType == null) throw new ArgumentNullException("viewType");
DataTemplate res = null;
try {
res = new DataTemplate() { VisualTree = new FrameworkElementFactory(viewType) };
res.Seal();
} catch {
res = CreateFallbackViewTemplate(GetErrorMessage_CannotCreateDataTemplateFromViewType(viewType.Name));
}
return res;
}
示例3: ContentPresenter
//------------------------------------------------------
//
// Constructors
//
//------------------------------------------------------
static ContentPresenter()
{
DataTemplate template;
FrameworkElementFactory text;
Binding binding;
// Default template for strings when hosted in ContentPresener with RecognizesAccessKey=true
template = new DataTemplate();
text = CreateAccessTextFactory();
text.SetValue(AccessText.TextProperty, new TemplateBindingExtension(ContentProperty));
template.VisualTree = text;
template.Seal();
s_AccessTextTemplate = template;
// Default template for strings
template = new DataTemplate();
text = CreateTextBlockFactory();
text.SetValue(TextBlock.TextProperty, new TemplateBindingExtension(ContentProperty));
template.VisualTree = text;
template.Seal();
s_StringTemplate = template;
// Default template for XmlNodes
template = new DataTemplate();
text = CreateTextBlockFactory();
binding = new Binding();
binding.XPath = ".";
text.SetBinding(TextBlock.TextProperty, binding);
template.VisualTree = text;
template.Seal();
s_XmlNodeTemplate = template;
// Default template for UIElements
template = new UseContentTemplate();
template.Seal();
s_UIElementTemplate = template;
// Default template for everything else
template = new DefaultTemplate();
template.Seal();
s_DefaultTemplate = template;
// Default template selector
s_DefaultTemplateSelector = new DefaultSelector();
}