presence_sample_v2/Presence.Desktop/ViewLocator.cs
2024-12-04 11:11:13 +03:00

20 lines
631 B
C#

using Avalonia.Controls;
using Avalonia.Controls.Templates;
using Presence.Desktop.ViewModels;
using System;
using Presence.Desktop.Views;
using ReactiveUI;
namespace Presence.Desktop
{
public class ViewLocator : IViewLocator
{
public IViewFor? ResolveView<T>(T? viewModel, string? contract = null) => viewModel switch
{
GroupViewModel groupViewModel => new GroupView{DataContext = groupViewModel},
PresenceViewModel presenceViewModel => new PresenceView{DataContext = presenceViewModel},
_ => throw new ArgumentOutOfRangeException(nameof(viewModel))
};
}
}