diff --git a/src/Ursa/Controls/Dialog/Dialog.cs b/src/Ursa/Controls/Dialog/Dialog.cs
index c7dc4a6..9ebecb2 100644
--- a/src/Ursa/Controls/Dialog/Dialog.cs
+++ b/src/Ursa/Controls/Dialog/Dialog.cs
@@ -26,7 +26,7 @@ public static class Dialog
Content = new TView(),
DataContext = vm,
};
- AssignOptionsToDialogWindow(window, options);
+ ConfigureDialogWindow(window, options);
owner ??= GetMainWindow();
if (owner is null)
{
@@ -52,7 +52,7 @@ public static class Dialog
Content = view,
DataContext = vm,
};
- AssignOptionsToDialogWindow(window, options);
+ ConfigureDialogWindow(window, options);
owner ??= GetMainWindow();
if (owner is null)
{
@@ -82,7 +82,7 @@ public static class Dialog
Content = new TView(),
DataContext = vm,
};
- AssignOptionsToDefaultDialogWindow(window, options);
+ ConfigureDefaultDialogWindow(window, options);
owner ??= GetMainWindow();
if (owner is null)
{
@@ -107,7 +107,7 @@ public static class Dialog
Content = view,
DataContext = vm,
};
- AssignOptionsToDefaultDialogWindow(window, options);
+ ConfigureDefaultDialogWindow(window, options);
owner ??= GetMainWindow();
if (owner is null)
{
@@ -136,7 +136,7 @@ public static class Dialog
Content = new TView(),
DataContext = vm,
};
- AssignOptionsToDialogWindow(window, options);
+ ConfigureDialogWindow(window, options);
owner ??= GetMainWindow();
if (owner is null)
{
@@ -163,7 +163,7 @@ public static class Dialog
Content = view,
DataContext = vm,
};
- AssignOptionsToDialogWindow(window, options);
+ ConfigureDialogWindow(window, options);
owner ??= GetMainWindow();
if (owner is null)
{
@@ -188,7 +188,7 @@ public static class Dialog
///
///
///
- private static void AssignOptionsToDialogWindow(DialogWindow window, DialogOptions? options)
+ private static void ConfigureDialogWindow(DialogWindow window, DialogOptions? options)
{
if (options is null)
{
@@ -214,7 +214,7 @@ public static class Dialog
///
///
///
- private static void AssignOptionsToDefaultDialogWindow(DefaultDialogWindow window, DialogOptions? options)
+ private static void ConfigureDefaultDialogWindow(DefaultDialogWindow window, DialogOptions? options)
{
if (options is null)
{
diff --git a/src/Ursa/Controls/Dialog/DialogControl.cs b/src/Ursa/Controls/Dialog/DialogControl.cs
index 4be0f03..17e4b98 100644
--- a/src/Ursa/Controls/Dialog/DialogControl.cs
+++ b/src/Ursa/Controls/Dialog/DialogControl.cs
@@ -76,9 +76,10 @@ public class DialogControl: ContentControl
}
- public Task ShowAsync()
- {
- var tcs = new TaskCompletionSource();
+ public Task ShowAsync(CancellationToken? token = default)
+ {
+ var tcs = new TaskCompletionSource();
+ token?.Register(Close);
void OnCloseHandler(object sender, object? args)
{
if (args is T result)
diff --git a/src/Ursa/Controls/Dialog/OverlayDialog.cs b/src/Ursa/Controls/Dialog/OverlayDialog.cs
index 7ae48e8..7635938 100644
--- a/src/Ursa/Controls/Dialog/OverlayDialog.cs
+++ b/src/Ursa/Controls/Dialog/OverlayDialog.cs
@@ -99,7 +99,7 @@ public static class OverlayDialog
}
public static Task ShowModal(TViewModel vm, string? hostId = null,
- OverlayDialogOptions? options = null)
+ OverlayDialogOptions? options = null, CancellationToken? token = default)
where TView: Control, new()
{
var host = OverlayDialogManager.GetHost(hostId);
@@ -111,11 +111,11 @@ public static class OverlayDialog
};
ConfigureDefaultDialogControl(t, options);
host?.AddModalDialog(t);
- return t.ShowAsync();
+ return t.ShowAsync(token);
}
public static Task ShowModal(Control control, object? vm, string? hostId = null,
- OverlayDialogOptions? options = null)
+ OverlayDialogOptions? options = null, CancellationToken? token = default)
{
var host = OverlayDialogManager.GetHost(hostId);
if (host is null) return Task.FromResult(DialogResult.None);
@@ -126,11 +126,11 @@ public static class OverlayDialog
};
ConfigureDefaultDialogControl(t, options);
host?.AddModalDialog(t);
- return t.ShowAsync();
+ return t.ShowAsync(token);
}
public static Task ShowCustomModal(TViewModel vm, string? hostId = null,
- OverlayDialogOptions? options = null)
+ OverlayDialogOptions? options = null, CancellationToken? token = default)
where TView: Control, new()
{
var host = OverlayDialogManager.GetHost(hostId);
@@ -142,11 +142,11 @@ public static class OverlayDialog
};
ConfigureDialogControl(t, options);
host?.AddModalDialog(t);
- return t.ShowAsync();
+ return t.ShowAsync(token);
}
public static Task ShowCustomModal(Control control, object? vm, string? hostId = null,
- OverlayDialogOptions? options = null)
+ OverlayDialogOptions? options = null, CancellationToken? token = default)
{
var host = OverlayDialogManager.GetHost(hostId);
if (host is null) return Task.FromResult(default(TResult));
@@ -157,11 +157,11 @@ public static class OverlayDialog
};
ConfigureDialogControl(t, options);
host?.AddModalDialog(t);
- return t.ShowAsync();
+ return t.ShowAsync(token);
}
public static Task ShowCustomModal(object? vm, string? hostId = null,
- OverlayDialogOptions? options = null)
+ OverlayDialogOptions? options = null, CancellationToken? token = default)
{
var host = OverlayDialogManager.GetHost(hostId);
if (host is null) return Task.FromResult(default(TResult));
@@ -175,7 +175,7 @@ public static class OverlayDialog
};
ConfigureDialogControl(t, options);
host?.AddModalDialog(t);
- return t.ShowAsync();
+ return t.ShowAsync(token);
}
private static void ConfigureDialogControl(DialogControl control, OverlayDialogOptions? options)
@@ -185,7 +185,7 @@ public static class OverlayDialog
control.VerticalAnchor = options.VerticalAnchor;
control.InitialHorizontalOffset =
control.HorizontalAnchor == HorizontalPosition.Center ? null : options.HorizontalOffset;
- control.InitialHorizontalOffset =
+ control.InitialVerticalOffset =
options.VerticalAnchor == VerticalPosition.Center ? null : options.VerticalOffset;
control.CanClickOnMaskToClose = options.CanClickOnMaskToClose;
}
@@ -197,7 +197,7 @@ public static class OverlayDialog
control.VerticalAnchor = options.VerticalAnchor;
control.InitialHorizontalOffset =
control.HorizontalAnchor == HorizontalPosition.Center ? null : options.HorizontalOffset;
- control.InitialHorizontalOffset =
+ control.InitialVerticalOffset =
options.VerticalAnchor == VerticalPosition.Center ? null : options.VerticalOffset;
control.CanClickOnMaskToClose = options.CanClickOnMaskToClose;
control.Mode = options.Mode;