diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-10-09 00:26:46 +0200 |
---|---|---|
committer | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-10-09 00:26:46 +0200 |
commit | bef1d59cffaae749661d0a5d90914839a54cc8e7 (patch) | |
tree | a05a726d27567bed093e77c194b1e0f9d2ac700f /BatchBeatmapDownloader/ViewLocator.cs | |
download | BatchBeatmapDownloader-master.tar.xz |
Diffstat (limited to 'BatchBeatmapDownloader/ViewLocator.cs')
-rw-r--r-- | BatchBeatmapDownloader/ViewLocator.cs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/BatchBeatmapDownloader/ViewLocator.cs b/BatchBeatmapDownloader/ViewLocator.cs new file mode 100644 index 0000000..e22d652 --- /dev/null +++ b/BatchBeatmapDownloader/ViewLocator.cs @@ -0,0 +1,23 @@ +using System; +using Avalonia.Controls; +using Avalonia.Controls.Templates; +using BatchBeatmapDownloader.ViewModels; + +namespace BatchBeatmapDownloader; + +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 = "Not Found: " + name }; + } + + public bool Match(object data) { + return data is ViewModelBase; + } +} |