added Toolkit.UI.Avalonia

This commit is contained in:
TheXamlGuy
2024-04-13 11:34:23 +01:00
parent 053d8a851e
commit 62a7e94e19
14 changed files with 432 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
using Avalonia;
using Avalonia.Controls.Primitives;
using Avalonia.Xaml.Interactivity;
using Toolkit.Foundation;
namespace Toolkit.UI.Avalonia;
public class NavigateBackAction :
AvaloniaObject,
IAction
{
public static readonly StyledProperty<string> ContextProperty =
AvaloniaProperty.Register<NavigateBackAction, string>(nameof(Context));
public static readonly StyledProperty<string> ScopeProperty =
AvaloniaProperty.Register<NavigateBackAction, string>(nameof(Scope));
public string Context
{
get => GetValue(ContextProperty);
set => SetValue(ContextProperty, value);
}
public string Scope
{
get => GetValue(ScopeProperty);
set => SetValue(ScopeProperty, value);
}
public object Execute(object? sender,
object? parameter)
{
if (sender is TemplatedControl control)
{
if (control.DataContext is IObservableViewModel observableViewModel)
{
observableViewModel.Publisher.Publish(new NavigateBack(Context
?? null, Scope ?? null)).GetAwaiter().GetResult();
}
}
return true;
}
}