wip
This commit is contained in:
@@ -24,7 +24,7 @@ public sealed class NavigateAction :
|
||||
{
|
||||
if (frameworkElement.DataContext is IObservableViewModel observableViewModel)
|
||||
{
|
||||
observableViewModel.Mediator.PublishAsync(new Navigate(Path))
|
||||
observableViewModel.Publisher.PublishAsync(new Navigate(Path))
|
||||
.GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,15 @@ using Microsoft.UI.Xaml.Markup;
|
||||
|
||||
namespace Hyperbar.UI.Windows;
|
||||
|
||||
public class ViewModelBinder
|
||||
{
|
||||
public void Bind(object viewModel,
|
||||
FrameworkElement view)
|
||||
{
|
||||
view.DataContext ??= viewModel;
|
||||
|
||||
}
|
||||
}
|
||||
public class ViewModelTemplate(IViewModelTemplateDescriptorProvider descriptors) :
|
||||
DataTemplateSelector,
|
||||
IViewModelTemplate
|
||||
@@ -19,7 +28,7 @@ public class ViewModelTemplate(IViewModelTemplateDescriptorProvider descriptors)
|
||||
DependencyObject container) =>
|
||||
SelectTemplateCore(item);
|
||||
|
||||
private DataTemplate CreateDataTemplate(IViewModelTemplateDescriptor descriptor)
|
||||
private static DataTemplate CreateDataTemplate(IViewModelTemplateDescriptor descriptor)
|
||||
{
|
||||
string xamlString = @$"
|
||||
<DataTemplate xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
|
||||
|
||||
@@ -1,17 +1,11 @@
|
||||
using Hyperbar.Interop.Windows;
|
||||
using Microsoft.UI.Windowing;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Windows.Graphics;
|
||||
using WinRT.Interop;
|
||||
|
||||
namespace Hyperbar.UI.Windows;
|
||||
|
||||
public class NavigationItemTemplateSelector :
|
||||
DataTemplateSelector
|
||||
{
|
||||
|
||||
}
|
||||
public static class WindowExtensions
|
||||
{
|
||||
public static WindowMessageListener CreateMessageListener(this Window window) =>
|
||||
|
||||
@@ -20,7 +20,7 @@ public class WindowHandler :
|
||||
public Task Handle(Navigate<Window> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (args.Template is Window window)
|
||||
if (args.View is Window window)
|
||||
{
|
||||
if (window.Content is FrameworkElement content)
|
||||
{
|
||||
@@ -33,8 +33,8 @@ public class WindowHandler :
|
||||
}
|
||||
}
|
||||
|
||||
//ViewModelBinder.Bind(args.ViewModel, content);
|
||||
window.Closed += HandleClosed;
|
||||
content.DataContext = args.Content;
|
||||
}
|
||||
|
||||
window.Activate();
|
||||
|
||||
Reference in New Issue
Block a user