private void InvokeEvent(object sender, PropertyChangedEventArgs eventArgs)
 {
     foreach (WeakReference <DependencyObject> Target in this.targets.ToArray())
     {
         DependencyObject TheTarget; //save target to allow deferred call below
         if (Target.TryGetTarget(out TheTarget))
         {
             if (TheTarget is FrameworkElement)
             {
                 TheTarget.Dispatcher.BeginInvoke(
                     DispatcherPriority.Normal,
                     (Action) delegate
                 {
                     ((FrameworkElement)TheTarget).RaiseEvent(new RoutedEventArgs(PropertyChangedRoutedEventFactory.GetRoutedEvent($"{eventArgs.PropertyName}Changed")));
                 });
             }
             else if (TheTarget is FrameworkContentElement)
             {
                 TheTarget.Dispatcher.BeginInvoke(
                     DispatcherPriority.Normal,
                     (Action) delegate
                 {
                     ((FrameworkContentElement)TheTarget).RaiseEvent(new RoutedEventArgs(PropertyChangedRoutedEventFactory.GetRoutedEvent($"{eventArgs.PropertyName}Changed")));
                 });
             }
             else
             {
                 throw new InvalidOperationException();
             }
         }
         else
         {
             this.targets.Remove(Target);
         }
     }
 }
 /// <summary>
 /// When implemented in a derived class, returns an object that is provided as the value of the target property for this markup extension.
 /// </summary>
 /// <returns>
 /// The object value to set on the property where the extension is applied.
 /// </returns>
 /// <param name="serviceProvider">A service provider helper that can provide services for the markup extension.</param>
 public override object ProvideValue(IServiceProvider serviceProvider) => PropertyChangedRoutedEventFactory.GetRoutedEvent($"{this.EventName}Changed");