mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-08-12 05:05:26 +02:00
misc: Created generic type RyujinxControl to allow for more unified control view model definitions
This commit is contained in:
18
src/Ryujinx/UI/Controls/RyujinxControl.cs
Normal file
18
src/Ryujinx/UI/Controls/RyujinxControl.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
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 => (TViewModel)DataContext ?? throw new InvalidOperationException(
|
||||
$"Underlying DataContext is not of type {typeof(TViewModel).AsPrettyString()}; " +
|
||||
$"Actual type is {DataContext?.GetType().AsPrettyString()}");
|
||||
set => DataContext = value;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user