看看这是否适合你。我对 RadWindow 对象进行了子类化。
public class MyWindow : RadWindow
{
#region Public Methods
/// <summary>
/// Alerts the specified message.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="width">The width.</param>
public static void Alert(string message, int width = 400 )
{
var dialogParams = new DialogParameters
{
Content = new TextBlock()
{
Text = message,
Width = width,
TextWrapping = TextWrapping.Wrap
},
Owner = Application.Current.MainWindow
};
RadWindow.Alert(dialogParams);
}
/// <summary>
/// Confirms the specified content.
/// </summary>
/// <param name="message">The content.</param>
/// <param name="closed">The closed.</param>
/// <param name="width">The width.</param>
public static void Confirm(string message, EventHandler<WindowClosedEventArgs> closed, int width = 400)
{
RadWindow.Confirm(new DialogParameters
{
Content = new TextBlock()
{
Text = message,
Width = width,
TextWrapping = TextWrapping.Wrap
},
Closed = closed,
Owner = Application.Current.MainWindow
});
}
#endregion Public Methods
}
然后像这样打电话...
MyWindow.Confirm(message,
delegate(object windowSender, WindowClosedEventArgs args)
{
if (args.DialogResult == true)
{
this.securityViewModel.UndeleteUser(fex.Detail.ExistingDeletedUserId.Value);
}
});