demo_trade/ViewLocator.cs
2024-10-04 15:41:04 +03:00

24 lines
892 B
C#

using Avalonia.Controls;
using Avalonia.Controls.Templates;
using demo_trade.ViewModels;
using ReactiveUI;
using System;
namespace demo_trade
{
public class ViewLocator : ReactiveUI.IViewLocator
{
public IViewFor? ResolveView<T>(T? viewModel, string? contract = null) => viewModel switch
{
LoginViewModel context => new LoginControl { DataContext = context },
GuestProductViewModel context => new GuestProductControl { DataContext = context },
ClientProductViewModel context => new ClientProductControl{ DataContext = context },
OrderShowDialogViewModel context => new OrderShowDialog{ DataContext = context},
OrderManagerViewModel context => new OrderManagerControl { DataContext = context },
_ => throw new ArgumentOutOfRangeException(nameof(viewModel))
};
}
}