Ejemplo n.º 1
0
        /// <summary>
        ///     Dynamically change this Expression sources (availiable only for NonShareable
        ///     Expressions)
        /// </summary>
        /// <remarks>
        ///     Expression must be in use on provided DependencyObject/DependencyProperty.
        ///     GetSources must reflect the old sources to be replaced by the provided newSources.
        /// </remarks>
        /// <param name="d">DependencyObject whose sources are to be updated</param>
        /// <param name="dp">The property that the Expression is set to</param>
        /// <param name="newSources">New sources</param>
        internal void ChangeSources(DependencyObject d, DependencyProperty dp, DependencySource[] newSources)
        {
            if (d == null && !ForwardsInvalidations)
            {
                throw new ArgumentNullException("d");
            }

            if (dp == null && !ForwardsInvalidations)
            {
                throw new ArgumentNullException("dp");
            }

            if (Shareable)
            {
                throw new InvalidOperationException(SR.Get(SRID.ShareableExpressionsCannotChangeSources));
            }

            DependencyObject.ValidateSources(d, newSources, this);

            // Additional validation in callee
            if (ForwardsInvalidations)
            {
                DependencyObject.ChangeExpressionSources(this, null, null, newSources);
            }
            else
            {
                DependencyObject.ChangeExpressionSources(this, d, dp, newSources);
            }
        }
Ejemplo n.º 2
0
 internal void ChangeSources(DependencyObject d, DependencyProperty dp, DependencySource[] newSources)
 {
     if (d == null && !this.ForwardsInvalidations)
     {
         throw new ArgumentNullException("d");
     }
     if (dp == null && !this.ForwardsInvalidations)
     {
         throw new ArgumentNullException("dp");
     }
     if (this.Shareable)
     {
         throw new InvalidOperationException("ShareableExpressionsCannotChangeSources");
     }
     DependencyObject.ValidateSources(d, newSources, this);
     if (this.ForwardsInvalidations)
     {
         DependencyObject.ChangeExpressionSources(this, null, null, newSources);
         return;
     }
     DependencyObject.ChangeExpressionSources(this, d, dp, newSources);
 }