[FriendAccessAllowed] // Built into Core, also used by Framework.
 internal static void ProvideContextForObject(
     DependencyObject context,
     DependencyObject newValue )
 {
     if (context != null)
     {
         context.ProvideSelfAsInheritanceContext(newValue, null);
     }
 }
Exemple #2
0
 // add inheritance context to a value
 private void AddInheritanceContext(DependencyObject inheritanceContext, object value)
 {
     // The VisualBrush.Visual property is the "friendliest", i.e. the
     // most likely to be accepted by the resource as FEs need to accept
     // being rooted by a VisualBrush.
     //
     // NOTE:  Freezable.Debug_VerifyContextIsValid() contains a special
     //        case to allow this with the VisualBrush.Visual property.
     //        Changes made here will require updates in Freezable.cs
     if (inheritanceContext.ProvideSelfAsInheritanceContext(value, VisualBrush.VisualProperty))
     {
         // if the assignment was successful, seal the value's InheritanceContext.
         // This makes sure the resource always gets inheritance-related information
         // from its point of definition, not from its point of use.
         DependencyObject doValue = value as DependencyObject;
         if (doValue != null)
         {
             doValue.IsInheritanceContextSealed = true;
         }
     }
 }