Exemplo n.º 1
0
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     this.TextBoxPopup = ((MahApps.Metro.Controls.MetroPopup)(target));
     
     #line 37 "..\..\..\TestWindow.xaml"
     this.TextBoxPopup.Closed += new MahApps.Metro.Controls.MetroPopup.PopupClosedEventHandler(this.TextBoxPopup_OnClosed);
     
     #line default
     #line hidden
     return;
     case 2:
     
     #line 39 "..\..\..\TestWindow.xaml"
     ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click);
     
     #line default
     #line hidden
     return;
     }
     this._contentLoaded = true;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Shows the MessageBox.
        /// </summary>
        /// <param name="messageText">The message text.</param>
        /// <param name="caption">The caption.</param>
        /// <param name="button">The button.</param>
        /// <param name="icon">The icon.</param>
        /// <param name="defaultResult">The default result.</param>
        /// <param name="messageBoxStyle">The style to be set.</param>
        /// <returns></returns>
        /// <exception cref="InvalidOperationException">Static methods for MessageBoxes are not available in XBAP.
        /// Use the instance ShowMessageBox methods instead.</exception>
        private static PopupResult ShowCore(string messageText, string caption,
                                            PopupButton button, PopupImage icon, PopupResult defaultResult,
                                            Style messageBoxStyle)
        {
            if (System.Windows.Interop.BrowserInteropHelper.IsBrowserHosted)
                throw new InvalidOperationException("Static methods for MessageBoxes are not available in XBAP. Use the instance ShowMessageBox methods instead.");

            var messageBox = new MetroPopup();
            messageBox.InitializeMessageBox(messageText, caption, button, icon, defaultResult);

            // Setting the style to null will inhibit any implicit styles      
            if (messageBoxStyle != null)
                messageBox.Style = messageBoxStyle;

            if (Application.Current.MainWindow.Content as Visual == null)
                return PopupResult.None;

            var layer = AdornerLayer.GetAdornerLayer(Application.Current.MainWindow.Content as Visual);
            var contentAd = new ControlAdorner(Application.Current.MainWindow.Content as UIElement) { Child = messageBox };

            layer.Add(contentAd);

            // Disable Closing of window while dialog is shown
            Application.Current.MainWindow.Closing += MainWindow_Closing;

            messageBox.ShowDialog();

            Application.Current.MainWindow.Closing -= MainWindow_Closing;

            layer.Remove(contentAd);

            return messageBox.PopupResult;
        }