aboutsummaryrefslogtreecommitdiff
path: root/ViewLocator.cs
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2021-02-01 01:05:42 -0500
committerAndrew Lee <alee14498@protonmail.com>2021-02-01 01:05:42 -0500
commitfe46c308ef3eb1be3c39eca680e9b01b6b749336 (patch)
tree6aa34c80cb7cc82f7553c5a039fb2c800052ef8f /ViewLocator.cs
parent5822baba1d687aab4b1ceafbad2382ae6b4703c3 (diff)
downloaderable-godot-fe46c308ef3eb1be3c39eca680e9b01b6b749336.tar.gz
erable-godot-fe46c308ef3eb1be3c39eca680e9b01b6b749336.tar.bz2
erable-godot-fe46c308ef3eb1be3c39eca680e9b01b6b749336.zip
Added project files
Diffstat (limited to 'ViewLocator.cs')
-rw-r--r--ViewLocator.cs32
1 files changed, 32 insertions, 0 deletions
diff --git a/ViewLocator.cs b/ViewLocator.cs
new file mode 100644
index 0000000..ded617c
--- /dev/null
+++ b/ViewLocator.cs
@@ -0,0 +1,32 @@
+using System;
+using Avalonia.Controls;
+using Avalonia.Controls.Templates;
+using Alee_Audio_Player.ViewModels;
+
+namespace Alee_Audio_Player
+{
+ public class ViewLocator : IDataTemplate
+ {
+ public bool SupportsRecycling => false;
+
+ public IControl Build(object data)
+ {
+ var name = data.GetType().FullName!.Replace("ViewModel", "View");
+ var type = Type.GetType(name);
+
+ if (type != null)
+ {
+ return (Control)Activator.CreateInstance(type)!;
+ }
+ else
+ {
+ return new TextBlock { Text = "Not Found: " + name };
+ }
+ }
+
+ public bool Match(object data)
+ {
+ return data is ViewModelBase;
+ }
+ }
+} \ No newline at end of file