Merge pull request #771 from yangjieshao/DialogControlClosed

增强 OverlayDialog 和 NumPad 的功能与交互体验
This commit is contained in:
Dong Bin
2025-09-19 18:15:35 +08:00
committed by GitHub
3 changed files with 28 additions and 5 deletions

View File

@@ -66,4 +66,8 @@ public class OverlayDialogOptions
public bool CanResize { get; set; }
public string? StyleClass { get; set; }
/// <summary>
/// </summary>
internal Delegate? OnDialogControlClosed { set; get; }
}

View File

@@ -34,6 +34,18 @@ public static class OverlayDialog
DataContext = vm,
};
ConfigureDefaultDialogControl(t, options);
if (options?.OnDialogControlClosed != null)
{
t.AddHandler(OverlayShared.OverlayFeedbackElement.ClosedEvent, options.OnDialogControlClosed);
t.AddHandler(OverlayShared.OverlayFeedbackElement.ClosedEvent, (s, _) =>
{
if (s is not DialogControlBase dc) return;
dc.RemoveHandler(OverlayShared.OverlayFeedbackElement.ClosedEvent, options.OnDialogControlClosed);
});
}
host.AddDialog(t);
}

View File

@@ -80,7 +80,14 @@ public class NumPad: TemplatedControl
Target = sender as InputElement ,
_targetInnerText = FindTextBoxInTarget((sender as InputElement)!)
};
OverlayDialog.Show(numPad, new object(), options: new OverlayDialogOptions() { Buttons = DialogButton.None });
OverlayDialog.Show(numPad, new object(), options: new OverlayDialogOptions()
{
Buttons = DialogButton.None,
OnDialogControlClosed = (object? ss, object? e) =>
{
numPad.Target?.Focus();
}
});
}
private static readonly Dictionary<Key, string> KeyInputMapping = new()