Browse Source

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.

pull/1645/head
brianlagunas_cp 15 years ago
parent
commit
15ae41e7a9
  1. 32
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/Implementation/MessageBox.cs
  2. 8
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/Themes/Generic.xaml

32
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

8
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/Themes/Generic.xaml

@ -256,10 +256,10 @@
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" x:Name="PART_YesButton" MinWidth="65" Margin="6,0,0,0" Visibility="Collapsed">Yes</Button>
<Button Grid.Column="1" x:Name="PART_NoButton" MinWidth="65" Margin="6,0,0,0" Visibility="Collapsed">No</Button>
<Button Grid.Column="2" x:Name="PART_OkButton" MinWidth="65" Margin="6,0,0,0" Visibility="Collapsed">OK</Button>
<Button Grid.Column="3" x:Name="PART_CancelButton" MinWidth="65" Margin="6,0,0,0" Visibility="Collapsed">Cancel</Button>
<Button Grid.Column="0" x:Name="PART_YesButton" MinWidth="65" Margin="6,0,0,0" Visibility="Collapsed" Content="{TemplateBinding YesButtonContent}" />
<Button Grid.Column="1" x:Name="PART_NoButton" MinWidth="65" Margin="6,0,0,0" Visibility="Collapsed" Content="{TemplateBinding NoButtonContent}" />
<Button Grid.Column="2" x:Name="PART_OkButton" MinWidth="65" Margin="6,0,0,0" Visibility="Collapsed" Content="{TemplateBinding OkButtonContent}" />
<Button Grid.Column="3" x:Name="PART_CancelButton" MinWidth="65" Margin="6,0,0,0" Visibility="Collapsed" Content="{TemplateBinding CancelButtonContent}" />
</Grid>
</Grid>
</Border>

Loading…
Cancel
Save