Files
@ a321f999a1ea
Branch filter:
Location: ATITD-Tools/Desert-Paint-Codex/Views/UserControlBase.cs - annotation
a321f999a1ea
1.2 KiB
text/x-csharp
Fix a crash when trying to reorder the reaction list after recording the first reaction in the list.
40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 | using System.Reactive.Disposables;
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.ReactiveUI;
using DesertPaintCodex.ViewModels;
using ReactiveUI;
namespace DesertPaintCodex.Views
{
public class UserControlBase<T> : ReactiveUserControl<T> where T : ViewModelBase
{
public UserControlBase()
{
this.WhenActivated((disposables) =>
{
ViewModel?.ShowMessageBoxDialog.RegisterHandler(ShowDialog<MessageBoxView,MessageBoxViewModel,int>).DisposeWith(disposables);
});
}
#region Dialog handlers
protected async Task ShowDialog<View, ViewModel, ReturnType>(
InteractionContext<ViewModel, ReturnType> interaction) where View : Window, new()
{
if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
View dialog = new() {DataContext = interaction.Input};
ReturnType result = await dialog.ShowDialog<ReturnType>(desktop.MainWindow);
interaction.SetOutput(result);
}
}
#endregion
}
}
|