-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathViewLocator.cs
More file actions
29 lines (25 loc) · 743 Bytes
/
ViewLocator.cs
File metadata and controls
29 lines (25 loc) · 743 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using Avalonia.Controls;
using Avalonia.Controls.Templates;
using Gamelist_Manager.ViewModels;
using Gamelist_Manager.Views;
namespace Gamelist_Manager;
public class ViewLocator : IDataTemplate
{
public Control? Build(object? param)
{
if (param is null)
return null;
// Explicit mapping of ViewModels to Views
return param switch
{
MediaPreviewViewModel => new MediaPreviewView(),
ScraperViewModel => new ScraperView(),
DatToolViewModel => new DatToolView(),
_ => new TextBlock { Text = "View not found for: " + param.GetType().Name }
};
}
public bool Match(object? data)
{
return data is ViewModelBase;
}
}