Files
Hyperbar/Hyperbar.UI.Windows/NavigateAction.cs
T
2024-02-09 20:58:50 +00:00

35 lines
925 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.Mediator.PublishAsync(new Navigate(Path))
.GetAwaiter().GetResult();
}
}
return true;
}
}