예제 #1
0
        private static void OnAttachedDataContextChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs eventArgs)
        {
            FrameworkElement element = (FrameworkElement)dependencyObject;

            // Copy new DataContext to MultiBindings.
            MultiBindings multiBindings = GetMultiBindings(element);

            multiBindings.SetDataContext(element.DataContext);
        }
예제 #2
0
        /// <summary>
        /// Sets the value of the <strong>MultiBindings</strong> attached property to a given
        /// <see cref="DependencyObject"/> object.
        /// </summary>
        /// <param name="obj">The object on which to set the property value.</param>
        /// <param name="value">The property value to set.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="obj"/> is <see langword="null"/>.
        /// </exception>
        public static void SetMultiBindings(DependencyObject obj, MultiBindings value)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }

            obj.SetValue(MultiBindingsProperty, value);
        }
예제 #3
0
        private static void OnMultiBindingsChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs eventArgs)
        {
            FrameworkElement element = (FrameworkElement)dependencyObject;

            // Bind element.DataContext to our attached property.
            // This allows us to get property changed callbacks when element.DataContext changes
            element.SetBinding(AttachedDataContextProperty, new Binding());

            MultiBindings bindings = GetMultiBindings(element);

            bindings.Initialize(element);
        }