Beispiel #1
0
 internal void PushData()
 {
     if (IsBinding)
     {
         Object value = bindToObject.GetValue();
         value = FormatObject(value);
         SetPropValue(value);
         modified = false;
     }
     else
     {
         SetPropValue(null);
     }
 }
Beispiel #2
0
        internal bool PushData(bool force)
        {
            object    dataSourceValue = null;
            Exception lastException   = null;

            // Don't push if update mode is 'Never' (unless caller is FORCING us to push)
            if (!force && ControlUpdateMode == ControlUpdateMode.Never)
            {
                return(false);
            }

            // Re-entrancy check between push and pull (new for Whidbey - requires FormattingEnabled)
            if (inPushOrPull && formattingEnabled)
            {
                return(false);
            }

            inPushOrPull = true;

            try {
                if (IsBinding)
                {
                    dataSourceValue = bindToObject.GetValue();
                    object controlValue = FormatObject(dataSourceValue);
                    SetPropValue(controlValue);
                    modified = false;
                }
                else
                {
                    SetPropValue(null);
                }
            }
            catch (Exception ex) {
                lastException = ex;

                // This try/catch is new for Whidbey. To preserve Everett behavior, re-throw the
                // exception unless this binding has formatting enabled (new Whidbey feature).
                if (!FormattingEnabled)
                {
                    throw;
                }
            }
            finally {
                inPushOrPull = false;
            }

            if (FormattingEnabled)
            {
                // Whidbey...

                // Raise the BindingComplete event, giving listeners a chance to process any errors that occured, and decide
                // whether the operation should be cancelled. But don't emit the event if we didn't actually update the control.
                BindingCompleteEventArgs args = CreateBindingCompleteEventArgs(BindingCompleteContext.ControlUpdate, lastException);
                OnBindingComplete(args);

                return(args.Cancel);
            }
            else
            {
                // Everett...

                // Do not emit BindingComplete events, or allow the operation to be cancelled.
                return(false);
            }
        }