moer changes
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user