diff --git a/src/Ryujinx.Ava/UI/Views/Input/ControllerInputView.axaml.cs b/src/Ryujinx.Ava/UI/Views/Input/ControllerInputView.axaml.cs index 338e04b6a..6252b1ff2 100644 --- a/src/Ryujinx.Ava/UI/Views/Input/ControllerInputView.axaml.cs +++ b/src/Ryujinx.Ava/UI/Views/Input/ControllerInputView.axaml.cs @@ -61,14 +61,15 @@ namespace Ryujinx.Ava.UI.Views.Input PointerPressed += MouseClick; - IKeyboard keyboard = (IKeyboard)(DataContext as ControllerInputViewModel).parentModel.AvaloniaKeyboardDriver.GetGamepad("0"); // Open Avalonia keyboard for cancel operations. + var viewModel = (DataContext as ControllerInputViewModel); + + IKeyboard keyboard = (IKeyboard)viewModel.parentModel.AvaloniaKeyboardDriver.GetGamepad("0"); // Open Avalonia keyboard for cancel operations. IButtonAssigner assigner = CreateButtonAssigner(isStick); _currentAssigner.ButtonAssigned += (sender, e) => { if (e.ButtonValue.HasValue) { - var viewModel = (DataContext as ControllerInputViewModel); var buttonValue = e.ButtonValue.Value; viewModel.parentModel.IsModified = true; diff --git a/src/Ryujinx.Ava/UI/Views/Input/KeyboardInputView.axaml.cs b/src/Ryujinx.Ava/UI/Views/Input/KeyboardInputView.axaml.cs index a5ccfc84b..58311a9ed 100644 --- a/src/Ryujinx.Ava/UI/Views/Input/KeyboardInputView.axaml.cs +++ b/src/Ryujinx.Ava/UI/Views/Input/KeyboardInputView.axaml.cs @@ -58,14 +58,15 @@ namespace Ryujinx.Ava.UI.Views.Input PointerPressed += MouseClick; - IKeyboard keyboard = (IKeyboard)(DataContext as KeyboardInputViewModel).parentModel.AvaloniaKeyboardDriver.GetGamepad("0"); // Open Avalonia keyboard for cancel operations. + var viewModel = (DataContext as KeyboardInputViewModel); + + IKeyboard keyboard = (IKeyboard)viewModel.parentModel.AvaloniaKeyboardDriver.GetGamepad("0"); // Open Avalonia keyboard for cancel operations. IButtonAssigner assigner = CreateButtonAssigner(); _currentAssigner.ButtonAssigned += (sender, e) => { if (e.ButtonValue.HasValue) { - var viewModel = (DataContext as KeyboardInputViewModel); var buttonValue = e.ButtonValue.Value; viewModel.parentModel.IsModified = true;