feat: initialize, setup demo. make sure MVVM works.
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Templates;
|
||||
using Ursa.Demo.ViewModels;
|
||||
|
||||
namespace Ursa.Demo.Converters;
|
||||
|
||||
public class MenuDataTemplateSelector: IDataTemplate
|
||||
{
|
||||
public IDataTemplate? MenuTemplate { get; set; }
|
||||
public IDataTemplate? SeparatorTemplate { get; set; }
|
||||
|
||||
public Control? Build(object? param)
|
||||
{
|
||||
if (param is MenuItemViewModel vm)
|
||||
{
|
||||
if (vm.IsSeparator) return SeparatorTemplate?.Build(vm);
|
||||
else return MenuTemplate?.Build(vm);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool Match(object? data)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user