feat: move to menu.

This commit is contained in:
rabbitism
2023-06-30 20:34:36 +08:00
parent 35582385ef
commit 518a825af3
24 changed files with 308 additions and 173 deletions

View File

@@ -11,12 +11,11 @@ public class MenuDataTemplateSelector: IDataTemplate
public Control? Build(object? param)
{
if (param is NavigationMenuItemViewModel vm)
if (param is MenuItemViewModel vm)
{
if (vm.IsSeparator) return SeparatorTemplate?.Build(vm);
else return MenuTemplate?.Build(vm);
}
return null;
}

View File

@@ -0,0 +1,29 @@
using System;
using Avalonia.Controls;
using Avalonia.Controls.Templates;
using Ursa.Demo.Pages;
namespace Ursa.Demo.Converters;
public class ViewLocator: IDataTemplate
{
public Control? Build(object? param)
{
if (param is null) return null;
var name = param.GetType().Name!.Replace("ViewModel", "");
var type = Type.GetType("Ursa.Demo.Pages."+name);
if (type != null)
{
return (Control)Activator.CreateInstance(type)!;
}
else
{
return new TextBlock { Text = "Not Found: " + name };
}
}
public bool Match(object? data)
{
return true;
}
}