mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
21 lines
600 B
C#
21 lines
600 B
C#
using System;
|
|
using Avalonia.ReactiveUI;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Wabbajack.App.ViewModels;
|
|
|
|
namespace Wabbajack.App.Views
|
|
{
|
|
public abstract class ViewBase<T> : ReactiveUserControl<T>
|
|
where T : ViewModelBase
|
|
{
|
|
public ViewBase(bool createViewModel = true)
|
|
{
|
|
if (createViewModel)
|
|
{
|
|
ViewModel = App.Services.GetService<T>();
|
|
if (ViewModel == null)
|
|
throw new Exception($"View model {typeof(T)} not found, did you forget to add it to DI?");
|
|
}
|
|
}
|
|
}
|
|
} |