private static void SaveMultibindingInfoForFutureAccess(MultiBindingTargetInfo multiBindingTargetInfo, MultiBinding multiBinding)
        {
            var frameworkElement = multiBindingTargetInfo.FrameworkElement;
            RoutedEventHandler unloadedEventHandler = null;

            unloadedEventHandler += (sender, args) =>
            {
                frameworkElement.Unloaded -= unloadedEventHandler;

                MultiBindings.Remove(multiBindingTargetInfo);
            };
            frameworkElement.Unloaded += unloadedEventHandler;

            MultiBindings[multiBindingTargetInfo] = multiBinding;
        }
        private static void OnMultiBindingsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var associatedObject = (FrameworkElement)d;
            var multiBindings    = (MultiBindingCollection)e.NewValue;

            multiBindings.ForEach(multiBinding =>
            {
                var targetPropertyName          = multiBinding.TargetProperty;
                var dependencyPropertyOwnerType = multiBinding.IsBindingToAttachedProperty
                    ? multiBinding.AttachedPropertyOwnerTypeProvider.GetType()
                    : associatedObject.GetType();
                var targetDependencyProperty = dependencyPropertyOwnerType.ExtractDependencyProperty(targetPropertyName);
                if (targetDependencyProperty == null)
                {
                    throw new InvalidOperationException($"{targetPropertyName} is not a DependencyProperty.");
                }
                var multiBindingTargetInfo = new MultiBindingTargetInfo(associatedObject, targetDependencyProperty);
                SaveMultibindingInfoForFutureAccess(multiBindingTargetInfo, multiBinding);
                multiBinding.OnAttached(associatedObject);
            });
        }
        internal static MultiBinding GetMultiBindingFor(FrameworkElement frameworkElement, DependencyProperty dependencyProperty)
        {
            var dependencyPropertyInfo = new MultiBindingTargetInfo(frameworkElement, dependencyProperty);

            return(MultiBindings.ContainsKey(dependencyPropertyInfo) ? MultiBindings[dependencyPropertyInfo] : null);
        }