feat: implement closing related features.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user