feat: WIP dialog window.
This commit is contained in:
30
src/Ursa/Controls/Dialog/DialogWindow.cs
Normal file
30
src/Ursa/Controls/Dialog/DialogWindow.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Metadata;
|
||||
using Avalonia.Controls.Primitives;
|
||||
|
||||
namespace Ursa.Controls;
|
||||
|
||||
[TemplatePart(PART_CloseButton, typeof(Button))]
|
||||
public class DialogWindow: Window
|
||||
{
|
||||
public const string PART_CloseButton = "PART_CloseButton";
|
||||
|
||||
protected override Type StyleKeyOverride { get; } = typeof(DialogWindow);
|
||||
|
||||
private Button? _closeButton;
|
||||
|
||||
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
|
||||
{
|
||||
base.OnApplyTemplate(e);
|
||||
_closeButton = e.NameScope.Find<Button>(PART_CloseButton);
|
||||
|
||||
if (_closeButton != null)
|
||||
{
|
||||
_closeButton.Click += (sender, args) =>
|
||||
{
|
||||
Close();
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user