本文整理汇总了C#中System.Windows.FrameworkTemplate.LoadContent方法的典型用法代码示例。如果您正苦于以下问题:C# FrameworkTemplate.LoadContent方法的具体用法?C# FrameworkTemplate.LoadContent怎么用?C# FrameworkTemplate.LoadContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.FrameworkTemplate
的用法示例。
在下文中一共展示了FrameworkTemplate.LoadContent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetHeaderFooterVisualFromDataTemplate
private ContainerVisual GetHeaderFooterVisualFromDataTemplate(FrameworkTemplate template, Rect container)
{
if (template == null)
{
return null;
}
var doc = Source as PrintableDocument;
var content = template.LoadContent() as FrameworkElement;
content.DataContext = doc.DataContext;
var width = _definition.PageSize.Width - _definition.Margins.Left - _definition.Margins.Right;
content.Measure(_definition.PageSize);
content.Arrange(new Rect(container.X, container.Y, width, content.DesiredSize.Height));
content.UpdateLayout();
var visual = new ContainerVisual();
visual.Children.Add(content);
return visual;
}
示例2: GetModelContentSize
private Size GetModelContentSize(object dataModel, FrameworkTemplate modelTemplate, Size availableSize)
{
FrameworkElement content = null;
if (modelTemplate == null)
{
return Size.Empty;
}
content = modelTemplate.LoadContent() as FrameworkElement;
if (content == null)
{
return Size.Empty;
}
content.DataContext = dataModel;
content.Measure(availableSize);
return content.DesiredSize;
}
示例3: ApplyTemplateContent
//.........这里部分代码省略.........
if (feContainer != null && EventTrace.IsEnabled(EventTrace.Keyword.KeywordXamlBaml, EventTrace.Level.Verbose))
{
string label = feContainer.Name;
if (label == null || label.Length == 0)
label = container.GetHashCode().ToString(System.Globalization.CultureInfo.InvariantCulture);
EventTrace.EventProvider.TraceEvent(EventTrace.Event.WClientParseInstVisTreeEnd, EventTrace.Keyword.KeywordXamlBaml, EventTrace.Level.Verbose,
String.Format(System.Globalization.CultureInfo.InvariantCulture, "Style.InstantiateSubTree for {0} {1}", container.GetType().Name, label));
}
}
// It's not a FEF-style template, is it a non-empty optimized one?
else if (frameworkTemplate != null && frameworkTemplate.HasXamlNodeContent)
{
// Yes, create from the optimized template content.
EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordXamlBaml, EventTrace.Level.Verbose, EventTrace.Event.WClientParseInstVisTreeBegin);
CheckForCircularReferencesInTemplateTree(container, frameworkTemplate );
// Container is considered ChildIndex '0' (Self), but,
// Container.ChildIndex isn't set
List<DependencyObject> affectedChildren = new List<DependencyObject>(lastChildIndex);
// Assign affectedChildren to container
TemplatedFeChildrenField.SetValue(container, affectedChildren);
DependencyObject treeRoot;
// Load the content
treeRoot = frameworkTemplate.LoadContent( container, affectedChildren);
Debug.Assert(treeRoot == null || treeRoot is FrameworkElement || treeRoot is FrameworkContentElement,
"Root node of tree must be a FrameworkElement or FrameworkContentElement. This should have been caught by set_VisualTree" );
visualsCreated = true;
if (feContainer != null && EventTrace.IsEnabled(EventTrace.Keyword.KeywordXamlBaml, EventTrace.Level.Verbose))
{
string label = feContainer.Name;
if (label == null || label.Length == 0)
label = container.GetHashCode().ToString(System.Globalization.CultureInfo.InvariantCulture);
EventTrace.EventProvider.TraceEvent(EventTrace.Event.WClientParseInstVisTreeEnd, EventTrace.Keyword.KeywordXamlBaml, EventTrace.Level.Verbose,
String.Format(System.Globalization.CultureInfo.InvariantCulture, "Style.InstantiateSubTree for {0} {1}", container.GetType().Name, label));
}
}
// No template was supplied. Allow subclasses to provide the template.
// This is currently only implemented for FrameworkElement's.
else
{
if (feContainer != null)
{
// This template will not be driven by the Style in any way.
// Rather, it will be built and initialized by the callee
// CALLBACK
#if DEBUG
Debug.Assert( feContainer._buildVisualTreeVerification == VerificationState.WaitingForBuildVisualTree,
"The BuildVisualTree override has triggered another call to itself. This is not good - something between the two Style.InstantiateSubTree calls on the stack is doing A Very Bad Thing.");
feContainer._buildVisualTreeVerification = VerificationState.WaitingForAddCustomTemplateRoot;