I have a custom messagebox done in wpf.
Custom messagebox view xaml:
<Window x:Class="My.XAML.Controls.Windows.WpfMessageBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WpfMessageBox" MinHeight="160"
MinWidth="420" MaxHeight="750" MaxWidth="750"
Background="Transparent"
SizeToContent="WidthAndHeight"
WindowStartupLocation="CenterScreen"
ShowInTaskbar="False" ResizeMode="NoResize"
WindowStyle="None" Topmost="True">
</Window>
From my main window I show this custom wpf messagebox window when user clicks on a button, as an example of the call from the button when it is clicked:
var messageBoxResult = WpfMessageBox.Show("Title", "MyMessage",
MessageBoxButton.YesNo, WpfMessageBox.MessageBoxImage.Warning);
if (messageBoxResult != MessageBoxResult.Yes) return;
*Custom messagebox code-behind xaml.cs:
public partial class WpfMessageBox : Window
{
private WpfMessageBox()
{
InitializeComponent();
}
public static MessageBoxResult Show(string caption, string text, MessageBoxButton button, MessageBoxImage image, EnumLocation location)
{
switch (location)
{
case EnumLocation.TopLeft:
// Locates at top left
break;
case EnumLocation.TopCenter:
// Locates at top center
break;
case EnumLocation.TopRight:
// Locates at top right
break;
// and so on with the rest of cases: middle left, middle center, middle right, bottom left, bottom center and bottom right.
}
}
}
By default this custom messagebox is opened at center of main screen.
What I would like to do now is to pass a parameter (enumeration) to my WpfMessageBox.Show method to indicate to my custom message box where I want it to be located within the main screen. Parameters would be these:
- Top Left
- Top Center
- Top Right
- Middle Left
- Middle Center
- Middle Right
- Botton Left
- Bottom Center
- Bottom Right
How can I do this?