mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2026-03-28 09:31:08 +00:00
25 lines
710 B
C#
25 lines
710 B
C#
using Avalonia.Controls;
|
|
using Gommon;
|
|
using Ryujinx.Ava.UI.ViewModels;
|
|
using System;
|
|
|
|
namespace Ryujinx.Ava.UI.Controls
|
|
{
|
|
public class RyujinxControl<TViewModel> : UserControl where TViewModel : BaseModel
|
|
{
|
|
public TViewModel ViewModel
|
|
{
|
|
get
|
|
{
|
|
if (DataContext is not TViewModel viewModel)
|
|
throw new InvalidOperationException(
|
|
$"Underlying DataContext is not of type {typeof(TViewModel).AsPrettyString()}; " +
|
|
$"Actual type is {DataContext?.GetType().AsPrettyString()}");
|
|
|
|
return viewModel;
|
|
}
|
|
set => DataContext = value;
|
|
}
|
|
}
|
|
}
|