Files
Hyperbar/Hyperbar.UI.Windows/NavigateAction.cs
T
TheXamlGuy 565c6866d8 wip
2024-02-10 20:19:01 +00:00

35 lines
926 B
C#

using Microsoft.UI.Xaml;
using Microsoft.Xaml.Interactivity;
namespace Hyperbar.UI.Windows;
public sealed class NavigateAction :
DependencyObject,
IAction
{
public static readonly DependencyProperty PathProperty =
DependencyProperty.Register(nameof(Path),
typeof(string), typeof(NavigateAction),
new PropertyMetadata(null));
public string Path
{
get => (string)GetValue(PathProperty);
set => SetValue(PathProperty, value);
}
public object Execute(object sender, object parameter)
{
if (sender is FrameworkElement frameworkElement)
{
if (frameworkElement.DataContext is IObservableViewModel observableViewModel)
{
observableViewModel.Publisher.PublishAsync(new Navigate(Path))
.GetAwaiter().GetResult();
}
}
return true;
}
}