Defines the abstract base class for task dialog buttons. Classes that inherit from this class will inherit the Text property defined in this class.
ContentProperty allows us to specify the text of the button as the child text of a button element in XAML, as well as explicitly set with 'Text=""' Note that this attribute is inherited, so it applies to command-links and radio buttons as well.
Inheritance: TaskDialogControl
Ejemplo n.º 1
0
        /// <summary>
        ///   Raises the closing event. Gives event subscriber a chance to prevent the dialog from closing, based on the
        ///   current state of the application and the button used to commit. Note that we don't have full access at
        ///   this stage to the full dialog state.
        /// </summary>
        /// <param name="id">The id for the <c>TaskDialog</c>.</param>
        /// <returns>An integer.</returns>
        internal int RaiseClosingEvent(int id)
        {
            EventHandler <TaskDialogClosingEventArgs> handler = Closing;

            if (handler != null)
            {
                var e = new TaskDialogClosingEventArgs();

                // Try to identify the button - is it a standard one?
                TaskDialogStandardButtons buttonClicked = MapButtonIdToStandardButton(id);

                // If not, it had better be a custom button...
                if (buttonClicked == TaskDialogStandardButtons.None)
                {
                    TaskDialogButtonBase customButton = GetButtonForId(id);

                    // ... or we have a problem.
                    if (customButton == null)
                    {
                        throw new InvalidOperationException(Resources.TaskDialogBadButtonId);
                    }

                    e.CustomButton     = customButton.Name;
                    e.TaskDialogResult = TaskDialogResult.CustomButtonClicked;
                }
                else
                {
                    e.TaskDialogResult = (TaskDialogResult)buttonClicked;
                }

                // Raise the event and determine how to proceed.
                handler(this, e);
                if (e.Cancel)
                {
                    return((int)Result.False);
                }
            }

            // It's okay to let the dialog close.
            return((int)Result.Ok);
        }