Skip to content

Commit

Permalink
Add missing view locator
Browse files Browse the repository at this point in the history
  • Loading branch information
acidicMercury8 committed Nov 23, 2024
1 parent 7462eee commit 46b1cf1
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/Dex.AnomalyCustom.Launcher.Avalonia/ViewLocator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Avalonia.Controls;
using Avalonia.Controls.Templates;

using ReactiveUI;

using System;

namespace Dex.AnomalyCustom.Launcher.Avalonia;

public class ViewLocator : IDataTemplate
{
public Control Build(object? data)
{
var name = data!.GetType()
.FullName!
.Replace("ViewModel", "View");
var type = Type.GetType(name);
if (type != null)
{
return (Control)Activator.CreateInstance(type)!;
}
return new TextBlock
{
Text = name,
};
}

public bool Match(object? data)
{
return data is ReactiveObject;
}
}

0 comments on commit 46b1cf1

Please sign in to comment.