/// <summary>Returns the <see cref="T:System.Windows.Data.BindingExpression" /> object associated with the specified binding target property on the specified object.</summary> /// <param name="target">The binding target object where <paramref name="dp" /> is.</param> /// <param name="dp">The binding target property from which to retrieve the <see cref="T:System.Windows.Data.BindingExpression" /> object.</param> /// <returns>The <see cref="T:System.Windows.Data.BindingExpression" /> object associated with the given property or <see langword="null" /> if none exists. If a <see cref="T:System.Windows.Data.PriorityBindingExpression" /> object is set on the property, the <see cref="P:System.Windows.Data.PriorityBindingExpression.ActiveBindingExpression" /> is returned.</returns> /// <exception cref="T:System.ArgumentNullException">The <paramref name="target" /> and <paramref name="dp" /> parameters cannot be <see langword="null" />.</exception> // Token: 0x06001A30 RID: 6704 RVA: 0x0007D164 File Offset: 0x0007B364 public static BindingExpression GetBindingExpression(DependencyObject target, DependencyProperty dp) { BindingExpressionBase bindingExpressionBase = BindingOperations.GetBindingExpressionBase(target, dp); PriorityBindingExpression priorityBindingExpression = bindingExpressionBase as PriorityBindingExpression; if (priorityBindingExpression != null) { bindingExpressionBase = priorityBindingExpression.ActiveBindingExpression; } return(bindingExpressionBase as BindingExpression); }
/// <summary> /// Retrieve a BindingExpression. /// </summary> /// <remarks> /// This method returns null if no Binding has been set on the given /// property. /// </remarks> /// <param name="target">object from which to retrieve the BindingExpression</param> /// <param name="dp">property from which to retrieve the BindingExpression</param> /// <exception cref="ArgumentNullException"> target and dp cannot be null </exception> public static BindingExpression GetBindingExpression(DependencyObject target, DependencyProperty dp) { BindingExpressionBase expr = GetBindingExpressionBase(target, dp); PriorityBindingExpression pb = expr as PriorityBindingExpression; if (pb != null) { expr = pb.ActiveBindingExpression; } return(expr as BindingExpression); }
//------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ // Create a new BindingExpression from the given Binding description internal static PriorityBindingExpression CreateBindingExpression(DependencyObject d, DependencyProperty dp, PriorityBinding binding, BindingExpressionBase owner) { FrameworkPropertyMetadata fwMetaData = dp.GetMetadata(d.DependencyObjectType) as FrameworkPropertyMetadata; if ((fwMetaData != null && !fwMetaData.IsDataBindingAllowed) || dp.ReadOnly) { throw new ArgumentException(SR.Get(SRID.PropertyNotBindable, dp.Name), "dp"); } // create the BindingExpression PriorityBindingExpression bindExpr = new PriorityBindingExpression(binding, owner); return(bindExpr); }
//------------------------------------------------------ // // Protected Methods // //------------------------------------------------------ /// <summary> /// Create an appropriate expression for this Binding, to be attached /// to the given DependencyProperty on the given DependencyObject. /// </summary> internal override BindingExpressionBase CreateBindingExpressionOverride(DependencyObject target, DependencyProperty dp, BindingExpressionBase owner) { return(PriorityBindingExpression.CreateBindingExpression(target, dp, this, owner)); }
//------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ // Create a new BindingExpression from the given Binding description internal static PriorityBindingExpression CreateBindingExpression(DependencyObject d, DependencyProperty dp, PriorityBinding binding, BindingExpressionBase owner) { FrameworkPropertyMetadata fwMetaData = dp.GetMetadata(d.DependencyObjectType) as FrameworkPropertyMetadata; if ((fwMetaData != null && !fwMetaData.IsDataBindingAllowed) || dp.ReadOnly) throw new ArgumentException(SR.Get(SRID.PropertyNotBindable, dp.Name), "dp"); // create the BindingExpression PriorityBindingExpression bindExpr = new PriorityBindingExpression(binding, owner); return bindExpr; }