feat: initialize, setup demo. make sure MVVM works.

This commit is contained in:
rabbitism
2024-02-21 02:15:30 +08:00
parent 3247a37105
commit 76da0b3616
16 changed files with 313 additions and 0 deletions

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;
}
}