demo_trade/ViewLocator.cs

24 lines
892 B
C#
Raw Normal View History

2024-10-04 12:41:04 +00:00
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))
};
}
}