Initialization

Just add the Gat.Controls.MessageBox.dll to your References. No further dependencies are needed.

Usage

General

Gat.Controls.MessageBoxView messageBox = new Gat.Controls.MessageBoxView();
Gat.Controls.MessageBoxViewModel vm = (Gat.Controls.MessageBoxViewModel)messageBox.FindResource("ViewModel");
vm.Show("Message..", "Caption", Gat.Controls.MessageBoxButton.OkCancel, Gat.Controls.MessageBoxImage.Question);

More Customized

Gat.Controls.MessageBoxView messageBox = new Gat.Controls.MessageBoxView();
Gat.Controls.MessageBoxViewModel vm = (Gat.Controls.MessageBoxViewModel)messageBox.FindResource("ViewModel");

vm.Message = "This is a message: MessageMessageMessageMessageMessageMessageMessageMessageMessageMessageMessageMessageMessageMessageMessageMessageEEE";
vm.Ok = "Left";
vm.Cancel = "Right";
vm.Yes= "Top";
vm.No= "Bottom";
vm.OkVisibility = true;
vm.CancelVisibility = true;
vm.YesVisibility = true;
vm.NoVisibility = true;
vm.Image = new BitmapImage(new System.Uri("pack://application:,,,/Image.bmp"));
vm.Caption = "Test Message";

// Center functionality
vm.Position = MessageBoxPosition.CenterOwner;
vm.Owner = this;

vm.Show();

Customized2.png

Taking result into account

Gat.Controls.MessageBoxResult result = vm.Show();
if(result == Gat.Controls.MessageBoxResult.Ok)
{
...
}

Last edited May 18, 2016 at 10:41 PM by kittof, version 4

Comments

andycambo Jan 23 at 2:45 PM 
Hi,
Nice project. I've successfully have it added in a WPF application. The only issue I'm having is getting the message box to be in the center.

I've tried the code suggested but get errors:
vm.Position = MessageBoxPosition.CenterOwner; (ERROR: The name 'MessageBoxPosition' does not exist in the current context_
vm.Owner = this; (ERROR: CMP.ViewModel.ActionListViewModel' to 'System.Windows.Window')

I've tried:
vm.Owner = Application.Current.MainWindow;
vm.Position = Gat.Controls.MessageBoxPosition.CenterOwner;

but the box still isn't in the center.

Any ideas?