DialogControl 增加 ShowCustom 方法
This commit is contained in:
@@ -24,6 +24,19 @@ public static class Dialog
|
||||
return await ShowCustomModalAsync<TView, TViewModel, TResult>(mainWindow, vm);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show a Window Dialog that with all content fully customized.
|
||||
/// </summary>
|
||||
/// <param name="vm"></param>
|
||||
/// <typeparam name="TView"></typeparam>
|
||||
/// <typeparam name="TViewModel"></typeparam>
|
||||
/// <returns></returns>
|
||||
public static void ShowCustom<TView, TViewModel>(TViewModel vm)
|
||||
where TView : Control, new()
|
||||
{
|
||||
var mainWindow = GetMainWindow();
|
||||
ShowCustom<TView, TViewModel>(mainWindow, vm);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show a Window Modal Dialog that with all content fully customized. And the owner of the dialog is specified.
|
||||
@@ -54,6 +67,33 @@ public static class Dialog
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Show a Window Dialog that with all content fully customized. And the owner of the dialog is specified.
|
||||
/// </summary>
|
||||
/// <param name="owner"></param>
|
||||
/// <param name="vm"></param>
|
||||
/// <typeparam name="TView"></typeparam>
|
||||
/// <typeparam name="TViewModel"></typeparam>
|
||||
/// <returns></returns>
|
||||
public static void ShowCustom<TView, TViewModel>(Window? owner, TViewModel? vm)
|
||||
where TView: Control, new()
|
||||
{
|
||||
var window = new DialogWindow
|
||||
{
|
||||
Content = new TView { DataContext = vm },
|
||||
DataContext = vm,
|
||||
};
|
||||
if (owner is null)
|
||||
{
|
||||
window.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
window.Show(owner);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<DialogResult> ShowModalAsync<TView, TViewModel>(
|
||||
Window? owner,
|
||||
TViewModel vm,
|
||||
@@ -170,4 +210,5 @@ public static class OverlayDialog
|
||||
host?.AddDialog(t);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user