本文整理汇总了C#中MS.Internal.FrameworkObject类的典型用法代码示例。如果您正苦于以下问题:C# FrameworkObject类的具体用法?C# FrameworkObject怎么用?C# FrameworkObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FrameworkObject类属于MS.Internal命名空间,在下文中一共展示了FrameworkObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindResourceInternal
// FindResourceInternal(fe/fce) Defaults: none
internal static object FindResourceInternal(
FrameworkElement fe,
FrameworkContentElement fce,
DependencyProperty dp,
object resourceKey,
object unlinkedParent,
bool allowDeferredResourceReference,
bool mustReturnDeferredResourceReference,
DependencyObject boundaryElement,
bool isImplicitStyleLookup,
out object source)
{
object value;
InheritanceBehavior inheritanceBehavior = InheritanceBehavior.Default;
if( TraceResourceDictionary.IsEnabled )
{
FrameworkObject element = new FrameworkObject(fe, fce);
TraceResourceDictionary.Trace(
TraceEventType.Start,
TraceResourceDictionary.FindResource,
element.DO,
resourceKey );
}
try
{
// First try to find the resource in the tree
if (fe != null || fce != null || unlinkedParent != null)
{
value = FindResourceInTree(fe, fce, dp, resourceKey, unlinkedParent, allowDeferredResourceReference, mustReturnDeferredResourceReference, boundaryElement,
out inheritanceBehavior, out source);
if (value != DependencyProperty.UnsetValue)
{
return value;
}
}
// Then we try to find the resource in the App's Resources
Application app = Application.Current;
if (app != null &&
(inheritanceBehavior == InheritanceBehavior.Default ||
inheritanceBehavior == InheritanceBehavior.SkipToAppNow ||
inheritanceBehavior == InheritanceBehavior.SkipToAppNext))
{
value = app.FindResourceInternal(resourceKey, allowDeferredResourceReference, mustReturnDeferredResourceReference);
if (value != null)
{
source = app;
if( TraceResourceDictionary.IsEnabled )
{
TraceResourceDictionary.TraceActivityItem(
TraceResourceDictionary.FoundResourceInApplication,
resourceKey,
value );
}
return value;
}
}
// Then we try to find the resource in the SystemResources but that is only if we aren't
// doing an implicit style lookup. Implicit style lookup will stop at the app.
if (!isImplicitStyleLookup &&
inheritanceBehavior != InheritanceBehavior.SkipAllNow &&
inheritanceBehavior != InheritanceBehavior.SkipAllNext)
{
value = SystemResources.FindResourceInternal(resourceKey, allowDeferredResourceReference, mustReturnDeferredResourceReference);
if (value != null)
{
source = SystemResourceHost.Instance;
if( TraceResourceDictionary.IsEnabled )
{
TraceResourceDictionary.TraceActivityItem(
TraceResourceDictionary.FoundResourceInTheme,
source,
resourceKey,
value );
}
return value;
}
}
}
finally
{
if( TraceResourceDictionary.IsEnabled )
{
FrameworkObject element = new FrameworkObject(fe, fce);
TraceResourceDictionary.Trace(
TraceEventType.Stop,
TraceResourceDictionary.FindResource,
//.........这里部分代码省略.........
示例2: InvalidateOnInheritablePropertyChange
/// <summary>
/// </summary>
internal static void InvalidateOnInheritablePropertyChange(
FrameworkElement fe,
FrameworkContentElement fce,
InheritablePropertyChangeInfo info,
bool skipStartNode)
{
DependencyProperty dp = info.Property;
FrameworkObject fo = new FrameworkObject(fe, fce);
Debug.Assert(fo.IsValid, "Node with the resources change notification must be an FE or an FCE.");
if (HasChildren(fe, fce))
{
// Spin up a DescendentsWalker only when
// the current node has children to walk
DependencyObject d = fo.DO;
DescendentsWalker<InheritablePropertyChangeInfo> walker = new DescendentsWalker<InheritablePropertyChangeInfo>(
TreeWalkPriority.LogicalTree, InheritablePropertyChangeDelegate, info);
walker.StartWalk(d, skipStartNode);
}
else if (!skipStartNode)
{
// Degenerate case when the current node is a leaf node and has no children.
// If the current node needs a notification, do so now.
OnInheritablePropertyChanged(fo.DO, info);
}
}
示例3: OnInheritedPropertyChanged
// raise the InheritedPropertyChanged event to mentees. Called from FE/FCE
// OnPropertyChanged
internal static void OnInheritedPropertyChanged(DependencyObject d,
ref InheritablePropertyChangeInfo info,
InheritanceBehavior inheritanceBehavior)
{
if (inheritanceBehavior == InheritanceBehavior.Default || IsForceInheritedProperty(info.Property))
{
FrameworkObject fo = new FrameworkObject(d);
fo.OnInheritedPropertyChanged(ref info);
}
}
示例4: InvalidateOnTreeChange
/// <summary>
/// Invalidate inheritable properties and resource
/// references during a tree change operation.
/// </summary>
internal static void InvalidateOnTreeChange(
FrameworkElement fe,
FrameworkContentElement fce,
DependencyObject parent,
bool isAddOperation)
{
Debug.Assert(fe != null || fce != null, "Node with the tree change notification must be an FE or an FCE.");
Debug.Assert(parent != null, "Must have a parent that the current node is connected to or disconnected from.");
// If the tree change is for a non-FE/FCE parent then we need to find
// the nearest FE/FCE parent inorder to propagate inheritance correctly.
FrameworkObject parentFO = new FrameworkObject(parent);
if (!parentFO.IsValid)
{
parent = parentFO.FrameworkParent.DO;
}
// We're interested in changes to the Template property that occur during
// the walk - if the template has changed we don't need to invalidate
// template-driven properties a second time. The HasTemplateChanged property
// is cleared on the first visit to each node, so that it means "template
// changed during the walk". But one relevant node isn't visited during
// the walk - the templated parent of the initial node. So we handle that now.
FrameworkObject fo = new FrameworkObject(fe, fce);
// Synchronize the ShouldLookupImplicitStyles flag with respect to the parent here
// because for the root node of a tree change UpdateStyleProperty happens right here
// in this method. And we need to have synchrnozed the ShouldLookupImplicitStyles
// before we re-query the Style property.
if (isAddOperation)
{
fo.SetShouldLookupImplicitStyles();
}
fo.Reset(fo.TemplatedParent);
fo.HasTemplateChanged = false;
DependencyObject d = (fe != null) ? (DependencyObject)fe : (DependencyObject)fce;
// during a tree walk to invalidate inherited properties, we typically
// call UpdateStyle from FE/FCE.InvalidateTreeDependentProperties. But
// for the root element of the tree change, we need to record old values
// for inherited properties before we've updated the inheritance parent;
// so do the updatestyle here before we record old values so that we
// capture any updates provided by styles.
if (fe != null)
{
if (fe.IsInitialized && !fe.HasLocalStyle)
{
// Clear the HasStyleChanged flag
fe.HasStyleChanged = false;
fe.HasStyleInvalidated = false;
fe.HasTemplateChanged = false;
fe.AncestorChangeInProgress = true;
fe.UpdateStyleProperty();
fe.AncestorChangeInProgress = false;
}
}
else
{
if (!fce.HasLocalStyle)
{
// Clear the HasStyleChanged flag
fce.HasStyleChanged = false;
fce.HasStyleInvalidated = false;
fce.AncestorChangeInProgress = true;
fce.UpdateStyleProperty();
fce.AncestorChangeInProgress = false;
}
}
if (HasChildren(fe, fce))
{
// Spin up a DescendentsWalker only when
// the current node has children to walk
// If there is another tree walk that has already visited the
// current node then we do not need to re-walk its sub-tree.
FrameworkContextData fcdata = FrameworkContextData.From(d.Dispatcher);
if (!fcdata.WasNodeVisited(d, TreeChangeDelegate))
{
// The TreeChangeInfo object is used here to track
// information that we have because we're doing a tree walk.
TreeChangeInfo parentInfo = new TreeChangeInfo(d, parent, isAddOperation);
// PrePostDescendentsWalker is used instead of the standard
// DescendentsWalker because we need a "post" callback to know when
// to pop the parent's InheritableProperties cache from the stack.
PrePostDescendentsWalker<TreeChangeInfo> walker = new PrePostDescendentsWalker<TreeChangeInfo>(
TreeWalkPriority.LogicalTree, TreeChangeDelegate, TreeChangePostDelegate, parentInfo);
fcdata.AddWalker(TreeChangeDelegate, walker);
//.........这里部分代码省略.........
示例5: OnResourcesChanged
/// <summary>
/// Process a resource change for the given DependencyObject.
/// Return true if the DO has resource references.
/// </summary>
internal static void OnResourcesChanged(
DependencyObject d,
ResourcesChangeInfo info,
bool raiseResourceChangedEvent)
{
Debug.Assert(d != null, "Must have non-null current node");
bool containsTypeOfKey = info.Contains(d.DependencyObjectType.SystemType, true /*isImplicitStyleKey*/);
bool isSystemResourcesChange = info.IsThemeChange;
bool isStyleResourcesChange = info.IsStyleResourcesChange;
bool isTemplateResourcesChange = info.IsTemplateResourcesChange;
bool isContainer = (info.Container == d);
FrameworkObject fo = new FrameworkObject(d);
// If a resource dictionary changed above this node then we need to
// synchronize the ShouldLookupImplicitStyles flag with respect to
// our parent here.
if (info.IsResourceAddOperation || info.IsCatastrophicDictionaryChange)
{
fo.SetShouldLookupImplicitStyles();
}
// Invalidate implicit and explicit resource
// references on current instance
if (fo.IsFE)
{
// If this is a FrameworkElement
FrameworkElement fe = fo.FE;
fe.HasStyleChanged = false; // detect style changes that arise from work done here
fe.HasStyleInvalidated = false;
fe.HasTemplateChanged = false; // detect template changes that arise from work done here
if (fe.HasResourceReference)
{
// Invalidate explicit ResourceReference properties on the current instance.
// If the Style property comes from an implicit resource reference that
// will be invalidated too.
InvalidateResourceReferences(fe, info);
// There is no need to invalidate the resources references on the
// container object if this call is a result of a style/template
// change. This is because the style/template change would have
// already invalidated all the container dependents and all the
// resources references on the container would have been a part of it.
if ((!isStyleResourcesChange && !isTemplateResourcesChange ) || !isContainer)
{
InvalidateStyleAndReferences(d, info, containsTypeOfKey);
}
}
else if (containsTypeOfKey &&
(fe.HasImplicitStyleFromResources || fe.Style == FrameworkElement.StyleProperty.GetMetadata(fe.DependencyObjectType).DefaultValue))
{
// If The Style property on the given instance has been
// fetched by an implicit resource lookup then
// it needs to be invalidated. Also we need to do this
// invalidation only if the dictionary/resources that is
// changing matches the implicit key used for the resource lookup.
// The StyleProperty does not need to be invalidated if this
// call is the result of a style change
if (!isStyleResourcesChange || !isContainer)
{
fe.UpdateStyleProperty();
}
}
// If there has been a Theme change then
// invalidate the ThemeStyleProperty
if (isSystemResourcesChange)
{
fe.UpdateThemeStyleProperty();
}
// Raise the ResourcesChanged Event so that ResourceReferenceExpressions
// on non-[FE/FCE] (example Freezables) listening for this can then update
// their values
if (raiseResourceChangedEvent && fe.PotentiallyHasMentees)
{
fe.RaiseClrEvent(FrameworkElement.ResourcesChangedKey, new ResourcesChangedEventArgs(info));
}
}
else
{
// If this is a FrameworkContentElement
FrameworkContentElement fce = fo.FCE;
fce.HasStyleChanged = false; // detect style changes that arise from work done here
fce.HasStyleInvalidated = false;
if (fce.HasResourceReference)
{
// Invalidate explicit ResourceReference properties on the current instance.
// If the Style property comes from an implicit resource reference that
// will be invalidated too.
//.........这里部分代码省略.........
示例6: IsInheritanceNode
/// <summary>
/// Determine if the current DependencyObject is a candidate for
/// producing inheritable values
/// </summary>
/// <remarks>
/// This is called by both InvalidateTree and GetValueCore
/// </remarks>
internal static bool IsInheritanceNode(
DependencyObject d,
DependencyProperty dp,
out InheritanceBehavior inheritanceBehavior)
{
// Assume can continue search
inheritanceBehavior = InheritanceBehavior.Default;
// Get Framework metadata (if exists)
FrameworkPropertyMetadata metadata = dp.GetMetadata(d.DependencyObjectType) as FrameworkPropertyMetadata;
// Check for correct type of metadata
if (metadata != null)
{
FrameworkObject fo = new FrameworkObject(d);
if (fo.IsValid)
{
// If parent is a Framework type, then check if it is at a
// tree separation boundary. Stop inheritance at the boundary unless
// overridden by the medata.OverridesInheritanceBehavior flag.
// GetValue from Parent only if instance is not a TreeSeparator
// or fmetadata.OverridesInheritanceBehavior is set to override separated tree behavior
if (fo.InheritanceBehavior != InheritanceBehavior.Default && !metadata.OverridesInheritanceBehavior)
{
// Hit a tree boundary
inheritanceBehavior = fo.InheritanceBehavior;
}
}
else
{
// If not a Framework type, then, this isn't an inheritance node.
// Only Framework types know how to inherit
return false;
}
// Check if metadata is marked as inheritable
if (metadata.Inherits)
{
return true;
}
}
// Not a framework type with inheritable metadata
return false;
}
示例7: InvalidateTreeDependentProperties
/// <summary>
/// Invalidate all the properties in the given
/// collection of inheritable properties
/// </summary>
/// <remarks>
/// This method is called during an [FE/FCE].OnAncestorChange
/// </remarks>
internal static FrugalObjectList<DependencyProperty> InvalidateTreeDependentProperties(
TreeChangeInfo info,
FrameworkElement fe,
FrameworkContentElement fce,
Style selfStyle,
Style selfThemeStyle,
ref ChildRecord childRecord,
bool isChildRecordValid,
bool hasStyleChanged,
bool isSelfInheritanceParent)
{
Debug.Assert(fe != null || fce != null, "Must have non-null current node");
DependencyObject d = fe != null ? (DependencyObject)fe : (DependencyObject)fce;
FrameworkObject fo = new FrameworkObject(fe, fce);
// Pull up the parent's InheritableProperties cache
FrugalObjectList<DependencyProperty> parentInheritableProperties = info.InheritablePropertiesStack.Peek();
// Loop through all cached inheritable
// to see if they should be invalidated.
int inheritablePropertiesCount = parentInheritableProperties != null ? parentInheritableProperties.Count : 0;
FrugalObjectList<DependencyProperty> currentInheritableProperties = null;
if (HasChildren(fe, fce))
{
currentInheritableProperties = new FrugalObjectList<DependencyProperty>(inheritablePropertiesCount);
}
info.ResetInheritableValueIndexer();
for (int i = 0; i < inheritablePropertiesCount; i++)
{
DependencyProperty inheritableProperty = parentInheritableProperties[i];
Debug.Assert(inheritableProperty.IsPotentiallyInherited, "if we got here, it means that this property is inheritable by someone");
PropertyMetadata metadata = inheritableProperty.GetMetadata(d);
// Invalidate only properties that are marked as inheritable.
// These are the ones that will be affected by an ancestor changes.
if (metadata.IsInherited)
{
FrameworkPropertyMetadata fMetadata = (FrameworkPropertyMetadata)metadata;
bool changed = InvalidateTreeDependentProperty(info, d, ref fo, inheritableProperty, fMetadata,
selfStyle, selfThemeStyle, ref childRecord, isChildRecordValid, hasStyleChanged, isSelfInheritanceParent);
// If a change is detected then add the inheritable property to
// the current list so that it can be used to invalidate further children
if (changed && currentInheritableProperties != null)
{
Debug.Assert(!currentInheritableProperties.Contains(inheritableProperty), "InheritableProperties list should not have duplicates");
// Children do not need to inherit properties across a tree boundary
// unless the property is set to override this behavior.
if (!SkipNow(fo.InheritanceBehavior) || fMetadata.OverridesInheritanceBehavior)
{
currentInheritableProperties.Add(inheritableProperty);
}
}
}
}
return currentInheritableProperties;
}
示例8: FindNamedFrameworkElement
// Given a FrameworkElement and a name string, this routine will try to find
// a node with Name property set to the given name. It will search all
// the child logical tree nodes of the given starting element.
// If the name string is null or an empty string, the given starting element
// is returned.
// If the name is found on a FrameworkContentElement, an exception is thrown
// If the name is not found attached to anything, an exception is thrown
internal static FrameworkElement FindNamedFrameworkElement( FrameworkElement startElement, string targetName )
{
FrameworkElement targetFE = null;
if( targetName == null || targetName.Length == 0 )
{
targetFE = startElement;
}
else
{
DependencyObject targetObject = null;
targetObject = LogicalTreeHelper.FindLogicalNode( startElement, targetName );
if( targetObject == null )
{
throw new ArgumentException( SR.Get(SRID.TargetNameNotFound, targetName));
}
FrameworkObject fo = new FrameworkObject(targetObject);
if( fo.IsFE )
{
targetFE = fo.FE;
}
else
{
throw new InvalidOperationException(SR.Get(SRID.NamedObjectMustBeFrameworkElement, targetName));
}
}
return targetFE;
}
示例9: FrameworkObject
/// <summary>
/// Find the element given name
/// </summary>
object INameScope.FindName(string name)
{
// _templatedParent is null if template.LoadContent() was responsible
if (_templatedParent != null)
{
FrameworkObject fo = new FrameworkObject(_templatedParent);
Debug.Assert(fo.IsFE);
if (fo.IsFE)
{
return StyleHelper.FindNameInTemplateContent(fo.FE, name, fo.FE.TemplateInternal);
}
else
{
return null;
}
}
else
{
if (_nameMap == null || name == null || name == String.Empty)
return null;
return _nameMap[name];
}
}
示例10: GetFrameworkParent
internal static bool GetFrameworkParent(FrameworkContentElement current, out FrameworkElement feParent, out FrameworkContentElement fceParent)
{
FrameworkObject fo = new FrameworkObject(null, current);
fo = fo.FrameworkParent;
feParent = fo.FE;
fceParent = fo.FCE;
return fo.IsValid;
}
示例11: GetTemplatedParentChildRecord
// Fetchs the specified childRecord for the given template. Returns true if successful.
internal static void GetTemplatedParentChildRecord(
DependencyObject templatedParent,
int childIndex,
out ChildRecord childRecord,
out bool isChildRecordValid)
{
FrameworkTemplate templatedParentTemplate = null;
isChildRecordValid = false;
childRecord = new ChildRecord(); // CS0177
if (templatedParent != null)
{
FrameworkObject foTemplatedParent = new FrameworkObject(templatedParent, true);
Debug.Assert( foTemplatedParent.IsFE );
// This node is the result of a style expansion
// Pick the owner for the VisualTree that generated this node
templatedParentTemplate = foTemplatedParent.FE.TemplateInternal;
Debug.Assert(templatedParentTemplate != null ,
"If this node is the result of a VisualTree expansion then it should have a parent template");
// Check if this Child Index is represented in FrameworkTemplate
if (templatedParentTemplate != null && ((0 <= childIndex) && (childIndex < templatedParentTemplate.ChildRecordFromChildIndex.Count)))
{
childRecord = templatedParentTemplate.ChildRecordFromChildIndex[childIndex];
isChildRecordValid = true;
}
}
}
示例12: FindTemplateResourceInTree
// Search the parent chain for a [Data|Table]Template in a ResourceDictionary.
private static object FindTemplateResourceInTree(DependencyObject target, ArrayList keys, int exactMatch, ref int bestMatch)
{
Debug.Assert(target != null, "Don't call FindTemplateResource with a null target object");
ResourceDictionary table;
object resource = null;
FrameworkObject fo = new FrameworkObject(target);
Debug.Assert(fo.IsValid, "Don't call FindTemplateResource with a target object that is neither a FrameworkElement nor a FrameworkContentElement");
while (fo.IsValid)
{
object candidate;
// -------------------------------------------
// Lookup ResourceDictionary on the current instance
// -------------------------------------------
// Fetch the ResourceDictionary
// for the given target element
table = GetInstanceResourceDictionary(fo.FE, fo.FCE);
if( table != null )
{
candidate = FindBestMatchInResourceDictionary( table, keys, exactMatch, ref bestMatch );
if (candidate != null)
{
resource = candidate;
if (bestMatch < exactMatch)
{
// Exact match found, stop here.
return resource;
}
}
}
// -------------------------------------------
// Lookup ResourceDictionary on the current instance's Style, if one exists.
// -------------------------------------------
table = GetStyleResourceDictionary(fo.FE, fo.FCE);
if( table != null )
{
candidate = FindBestMatchInResourceDictionary( table, keys, exactMatch, ref bestMatch );
if (candidate != null)
{
resource = candidate;
if (bestMatch < exactMatch)
{
// Exact match found, stop here.
return resource;
}
}
}
// -------------------------------------------
// Lookup ResourceDictionary on the current instance's Theme Style, if one exists.
// -------------------------------------------
table = GetThemeStyleResourceDictionary(fo.FE, fo.FCE);
if( table != null )
{
candidate = FindBestMatchInResourceDictionary( table, keys, exactMatch, ref bestMatch );
if (candidate != null)
{
resource = candidate;
if (bestMatch < exactMatch)
{
// Exact match found, stop here.
return resource;
}
}
}
// -------------------------------------------
// Lookup ResourceDictionary on the current instance's Template, if one exists.
// -------------------------------------------
table = GetTemplateResourceDictionary(fo.FE, fo.FCE);
if( table != null )
{
candidate = FindBestMatchInResourceDictionary( table, keys, exactMatch, ref bestMatch );
if (candidate != null)
{
resource = candidate;
if (bestMatch < exactMatch)
{
// Exact match found, stop here.
return resource;
}
}
}
// If the current element for resource lookup is marked such then abort
// lookup because resource lookup does not span tree boundaries
if (fo.IsValid && TreeWalkHelper.SkipNext(fo.InheritanceBehavior))
{
break;
}
//.........这里部分代码省略.........
示例13: FindResourceInTree
// FindResourceInTree(fe/fce) Defaults: none
internal static object FindResourceInTree(
FrameworkElement feStart,
FrameworkContentElement fceStart,
DependencyProperty dp,
object resourceKey,
object unlinkedParent,
bool allowDeferredResourceReference,
bool mustReturnDeferredResourceReference,
DependencyObject boundaryElement,
out InheritanceBehavior inheritanceBehavior,
out object source)
{
FrameworkObject startNode = new FrameworkObject(feStart, fceStart);
FrameworkObject fo = startNode;
object value;
Style style;
FrameworkTemplate frameworkTemplate;
Style themeStyle;
int loopCount = 0;
bool hasParent = true;
inheritanceBehavior = InheritanceBehavior.Default;
while (hasParent)
{
Debug.Assert(startNode.IsValid || unlinkedParent != null,
"Don't call FindResource with a null fe/fce and unlinkedParent");
if (loopCount > ContextLayoutManager.s_LayoutRecursionLimit)
{
// We suspect a loop here because the loop count
// has exceeded the MAX_TREE_DEPTH expected
throw new InvalidOperationException(SR.Get(SRID.LogicalTreeLoop));
}
else
{
loopCount++;
}
// -------------------------------------------
// Lookup ResourceDictionary on the current instance
// -------------------------------------------
style = null;
frameworkTemplate = null;
themeStyle = null;
if (fo.IsFE)
{
FrameworkElement fe = fo.FE;
value = fe.FindResourceOnSelf(resourceKey, allowDeferredResourceReference, mustReturnDeferredResourceReference);
if (value != DependencyProperty.UnsetValue)
{
source = fe;
if( TraceResourceDictionary.IsEnabled )
{
TraceResourceDictionary.TraceActivityItem(
TraceResourceDictionary.FoundResourceOnElement,
source,
resourceKey,
value );
}
return value;
}
if ((fe != startNode.FE) || StyleHelper.ShouldGetValueFromStyle(dp))
{
style = fe.Style;
}
// Fetch the Template
if ((fe != startNode.FE) || StyleHelper.ShouldGetValueFromTemplate(dp))
{
frameworkTemplate = fe.TemplateInternal;
}
// Fetch the ThemeStyle
if ((fe != startNode.FE) || StyleHelper.ShouldGetValueFromThemeStyle(dp))
{
themeStyle = fe.ThemeStyle;
}
}
else if (fo.IsFCE)
{
FrameworkContentElement fce = fo.FCE;
value = fce.FindResourceOnSelf(resourceKey, allowDeferredResourceReference, mustReturnDeferredResourceReference);
if (value != DependencyProperty.UnsetValue)
{
source = fce;
if( TraceResourceDictionary.IsEnabled )
{
TraceResourceDictionary.TraceActivityItem(
TraceResourceDictionary.FoundResourceOnElement,
source,
resourceKey,
value );
}
//.........这里部分代码省略.........
示例14: GetContainingFrameworkElement
internal static FrameworkObject GetContainingFrameworkElement(DependencyObject current)
{
FrameworkObject fo = new FrameworkObject(current);
while (!fo.IsValid && fo.DO != null)
{
// The current object is neither a FrameworkElement nor a
// FrameworkContentElement. We will now walk the "core"
// tree looking for one.
Visual visual;
Visual3D visual3D;
ContentElement ce;
if ((visual = fo.DO as Visual) != null)
{
fo.Reset(VisualTreeHelper.GetParent(visual));
}
else if ((ce = fo.DO as ContentElement) != null)
{
fo.Reset(ContentOperations.GetParent(ce));
}
else if ((visual3D = fo.DO as Visual3D) != null)
{
fo.Reset(VisualTreeHelper.GetParent(visual3D));
}
else
{
// The parent could be an application.
fo.Reset(null);
}
}
return fo;
}
示例15: OnSourceUpdated
// raise the SourceUpdatedEvent event (explicit polymorphism)
internal static void OnSourceUpdated(DependencyObject d, DependencyProperty dp)
{
DataTransferEventArgs args = new DataTransferEventArgs(d, dp);
args.RoutedEvent = Binding.SourceUpdatedEvent;
FrameworkObject fo = new FrameworkObject(d);
if (!fo.IsValid && d != null)
{
fo.Reset(Helper.FindMentor(d));
}
fo.RaiseEvent(args);
}