feat: implement closing related features.

This commit is contained in:
rabbitism
2024-01-22 17:27:11 +08:00
parent 9cff01c032
commit 5c62131a0a
6 changed files with 70 additions and 20 deletions

View File

@@ -13,15 +13,36 @@ public class DialogControl: ContentControl
private Button? _closeButton;
public event EventHandler OnClose;
public event EventHandler<object?> OnClose;
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
{
base.OnApplyTemplate(e);
if (_closeButton != null)
{
_closeButton.Click -= Close;
}
_closeButton = e.NameScope.Find<Button>(PART_CloseButton);
if (_closeButton is not null)
{
_closeButton.Click += Close;
}
}
public void Show()
{
}
private void Close(object sender, object args)
{
if (this.DataContext is IDialogContext context)
{
OnClose?.Invoke(this, context.DefaultCloseResult);
}
else
{
OnClose?.Invoke(this, null);
}
}
}