Пример #1
0
 public void Attach(DependencyObject dependencyObject)
 {
     if (dependencyObject != AssociatedObject)
     {
         if (AssociatedObject != null)
         {
             throw new InvalidOperationException(Properties.Resources.CannotHostTriggerActionMultipleTimesExceptionMessage);
         }
         if ((dependencyObject != null) && !AssociatedObjectTypeConstraint.IsAssignableFrom(dependencyObject.GetType()))
         {
             throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Properties.Resources.TypeConstraintViolatedExceptionMessage, new object[] { base.GetType().Name, dependencyObject.GetType().Name, AssociatedObjectTypeConstraint.Name }));
         }
         base.WritePreamble();
         associatedObject = dependencyObject;
         base.WritePostscript();
         OnAttached();
     }
 }
Пример #2
0
 public void Attach(DependencyObject dependencyObject)
 {
     if (dependencyObject != AssociatedObject)
     {
         if (AssociatedObject != null)
         {
             throw new InvalidOperationException("CannotHostTriggerMultipleTimesExceptionMessage");
         }
         if (dependencyObject != null && !AssociatedObjectTypeConstraint.IsAssignableFrom(dependencyObject.GetType()))
         {
             throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, "TypeConstraintViolatedExceptionMessage", new object[3]
             {
                 GetType().Name,
                 dependencyObject.GetType().Name,
                 AssociatedObjectTypeConstraint.Name
             }));
         }
         WritePreamble();
         associatedObject = dependencyObject;
         WritePostscript();
         Actions.Attach(dependencyObject);
         OnAttached();
     }
 }