Пример #1
0
        /// <summary>
        /// Displays a message box that has a message, title bar caption, button, and icon; and that returns a result.
        /// </summary>
        /// <param name="owner">The window owning the message box.</param>
        /// <param name="messageBoxText">A string that specifies the text to display.</param>
        /// <param name="icon">A MessageBoxImage value that specifies the icon to display.</param>
        /// <param name="button">A MessageBoxButton value that specifies which button or buttons to display.</param>
        /// <param name="caption">A string that specifies the title bar caption to display.</param>
        public static MessageBoxResult Show(System.Windows.Window owner, string messageBoxText, MessageBoxImage icon = MessageBoxImage.None, MessageBoxButton button = MessageBoxButton.OK, string caption = null)
        {
            var msg = new MessageBoxWindow(messageBoxText, caption, button, icon);

            // Imposta l'owner e usa lo stesso tema
            if (owner != null)
            {
                msg.Owner = owner;
                msg.WindowStartupLocation = WindowStartupLocation.CenterOwner;

                if (Theming.GetTheme(owner) is Theme theme)
                {
                    Theming.SetTheme(msg, theme);
                }
            }

            // Attendi la risposta
            msg.ShowDialog();

            return(msg.Result);
        }