From 15ae41e7a9d981ee7b4cb7e01a38d606b83c0502 Mon Sep 17 00:00:00 2001 From: brianlagunas_cp Date: Thu, 28 Jul 2011 19:12:33 +0000 Subject: [PATCH] MessageBox: added ability to define any content for the message box buttons. So you ar enot limited to just text such as "Yes" or "No", but instead you can it to any content such as UI elements and images. --- .../MessageBox/Implementation/MessageBox.cs | 32 +++++++++++++++++-- .../MessageBox/Themes/Generic.xaml | 8 ++--- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/Implementation/MessageBox.cs b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/Implementation/MessageBox.cs index 8b9de3df..0834679e 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/Implementation/MessageBox.cs +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/Implementation/MessageBox.cs @@ -73,6 +73,13 @@ namespace Microsoft.Windows.Controls set { SetValue(CaptionForegroundProperty, value); } } + public static readonly DependencyProperty CancelButtonContentProperty = DependencyProperty.Register("CancelButtonContent", typeof(object), typeof(MessageBox), new UIPropertyMetadata("Cancel")); + public object CancelButtonContent + { + get { return (object)GetValue(CancelButtonContentProperty); } + set { SetValue(CancelButtonContentProperty, value); } + } + public static readonly DependencyProperty CloseButtonStyleProperty = DependencyProperty.Register("CloseButtonStyle", typeof(Style), typeof(MessageBox), new PropertyMetadata(null)); public Style CloseButtonStyle { @@ -87,6 +94,20 @@ namespace Microsoft.Windows.Controls set { SetValue(ImageSourceProperty, value); } } + public static readonly DependencyProperty NoButtonContentProperty = DependencyProperty.Register("NoButtonContent", typeof(object), typeof(MessageBox), new UIPropertyMetadata("No")); + public object NoButtonContent + { + get { return (object)GetValue(NoButtonContentProperty); } + set { SetValue(NoButtonContentProperty, value); } + } + + public static readonly DependencyProperty OkButtonContentProperty = DependencyProperty.Register("OkButtonContent", typeof(object), typeof(MessageBox), new UIPropertyMetadata("OK")); + public object OkButtonContent + { + get { return (object)GetValue(OkButtonContentProperty); } + set { SetValue(OkButtonContentProperty, value); } + } + public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(MessageBox), new UIPropertyMetadata(String.Empty)); public string Text { @@ -115,6 +136,13 @@ namespace Microsoft.Windows.Controls set { SetValue(WindowOpacityProperty, value); } } + public static readonly DependencyProperty YesButtonContentProperty = DependencyProperty.Register("YesButtonContent", typeof(object), typeof(MessageBox), new UIPropertyMetadata("Yes")); + public object YesButtonContent + { + get { return (object)GetValue(YesButtonContentProperty); } + set { SetValue(YesButtonContentProperty, value); } + } + #endregion //Dependency Properties #endregion //Properties @@ -446,8 +474,8 @@ namespace Microsoft.Windows.Controls newWindow.AllowsTransparency = true; newWindow.Background = Brushes.Transparent; newWindow.Content = this; - newWindow.Owner = _owner ?? ResolveOwnerWindow(); - + newWindow.Owner = _owner ?? ResolveOwnerWindow(); + if (newWindow.Owner != null) newWindow.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner; else diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/Themes/Generic.xaml b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/Themes/Generic.xaml index efbd5084..bcc86f60 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/Themes/Generic.xaml +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/Themes/Generic.xaml @@ -256,10 +256,10 @@ - - - - +