presence/Presence.Desktop/ViewLocator.cs

20 lines
637 B
C#
Raw Normal View History

2024-11-24 18:05:17 +00:00
using Avalonia.Controls;
using Avalonia.Controls.Templates;
using Presence.Desktop.ViewModels;
using System;
2024-12-18 07:19:58 +00:00
using Presence.Desktop.Views;
using ReactiveUI;
2024-11-24 18:05:17 +00:00
namespace Presence.Desktop
{
2024-12-18 07:19:58 +00:00
public class ViewLocator : IViewLocator
2024-11-24 18:05:17 +00:00
{
2024-12-18 07:19:58 +00:00
public IViewFor? ResolveView<T>(T? viewModel, string? contract = null) => viewModel switch
2024-11-24 18:05:17 +00:00
{
2024-12-18 07:19:58 +00:00
GroupViewModel groupViewModel => new GroupView { DataContext = groupViewModel },
PresenceViewModel presenceViewModel => new PresenceView { DataContext = presenceViewModel },
_ => throw new ArgumentOutOfRangeException(nameof(viewModel))
};
2024-11-24 18:05:17 +00:00
}
}