本文整理汇总了C#中System.Windows.FrameworkTemplate.Seal方法的典型用法代码示例。如果您正苦于以下问题:C# FrameworkTemplate.Seal方法的具体用法?C# FrameworkTemplate.Seal怎么用?C# FrameworkTemplate.Seal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.FrameworkTemplate
的用法示例。
在下文中一共展示了FrameworkTemplate.Seal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetTemplateParentValues
//+----------------------------------------------------------------------------------------------------------------
//
// SetTemplateParentValues
//
// This method takes the "template parent values" (those that look like local values in the template), which
// are ordinarily shared, and sets them as local values on the FE/FCE that was just created. This is used
// during serialization.
//
//+----------------------------------------------------------------------------------------------------------------
internal static void SetTemplateParentValues(
string name,
object element,
FrameworkTemplate frameworkTemplate,
ref ProvideValueServiceProvider provideValueServiceProvider)
{
int childIndex;
// Loop through the shared values, and set them onto the element.
FrugalStructList<ChildRecord> childRecordFromChildIndex;
HybridDictionary childIndexFromChildName;
// Seal the template, and get the name->index and index->ChildRecord mappings
if (!frameworkTemplate.IsSealed)
{
frameworkTemplate.Seal();
}
childIndexFromChildName = frameworkTemplate.ChildIndexFromChildName;
childRecordFromChildIndex = frameworkTemplate.ChildRecordFromChildIndex;
// Calculate the child index
childIndex = StyleHelper.QueryChildIndexFromChildName(name, childIndexFromChildName);
// Do we have a ChildRecord for this index (i.e., there's some property set on it)?
if (childIndex < childRecordFromChildIndex.Count)
{
// Yes, get the record.
ChildRecord child = (ChildRecord)childRecordFromChildIndex[childIndex];
// Loop through the properties which are in some way set on this child
for (int i = 0; i < child.ValueLookupListFromProperty.Count; i++)
{
// And for each of those properties, loop through the potential values specified in the template
// for that property on that child.
for (int j = 0; j < child.ValueLookupListFromProperty.Entries[i].Value.Count; j++)
{
// Get this value (in valueLookup)
ChildValueLookup valueLookup;
valueLookup = (ChildValueLookup)child.ValueLookupListFromProperty.Entries[i].Value.List[j];
// See if this value is one that is considered to be locally set on the child element
if (valueLookup.LookupType == ValueLookupType.Simple
||
valueLookup.LookupType == ValueLookupType.Resource
||
valueLookup.LookupType == ValueLookupType.TemplateBinding)
{
// This shared value is for this element, so we'll set it.
object value = valueLookup.Value;
// If this is a TemplateBinding, put on an expression for it, so that it can
// be represented correctly (e.g. for serialization). Otherwise, keep it as an ME.
if (valueLookup.LookupType == ValueLookupType.TemplateBinding)
{
value = new TemplateBindingExpression(value as TemplateBindingExtension);
}
// Dynamic resources need to be converted to an expression also.
else if (valueLookup.LookupType == ValueLookupType.Resource)
{
value = new ResourceReferenceExpression(value);
}
// Bindings are handled as just an ME
// Set the value directly onto the element.
MarkupExtension me = value as MarkupExtension;
if (me != null)
{
// This is provided for completeness, but really there's only a few
// MEs that survive TemplateBamlRecordReader. E.g. NullExtension would
// have been converted to a null by now. There's only a few MEs that
//.........这里部分代码省略.........
示例2: UpdateTemplateCache
//
// This method
// 1. Updates the template cache for the given fe/fce
//
internal static void UpdateTemplateCache(
FrameworkElement fe,
FrameworkTemplate oldTemplate,
FrameworkTemplate newTemplate,
DependencyProperty templateProperty)
{
DependencyObject d = fe;
if (newTemplate != null)
{
newTemplate.Seal();
#if DEBUG
// Check if there is a cyclic reference between the condition properties on a
// style trigger that triggers the TemplateProperty and the values set by that
// Template's triggers on the container. This check is done only when we're
// not in the middle of updating Style or ThemeStyle.
if( StyleHelper.ShouldGetValueFromStyle(templateProperty)
&&
StyleHelper.ShouldGetValueFromThemeStyle(templateProperty))
{
Style style = fe.Style;
Style themeStyle = fe.ThemeStyle;
StyleHelper.CheckForCyclicReferencesInStyleAndTemplateTriggers(templateProperty, newTemplate, style, themeStyle);
}
#endif
}
// Update the template cache
fe.TemplateCache = newTemplate;
// Do template property invalidations. Note that some of the invalidations may be callouts
// that could turn around and query the template property on this node. Hence it is essential
// to update the template cache before we do this operation.
StyleHelper.DoTemplateInvalidations(fe, oldTemplate);
// Now look for triggers that might want their EnterActions or ExitActions
// to run immediately.
StyleHelper.ExecuteOnApplyEnterExitActions(fe, null, newTemplate);
}