Switch out dotnet ctk messenger for source gen Meditor

This commit is contained in:
Daniel Clark
2022-12-07 19:30:31 +00:00
parent 1cd2141ad5
commit 6df08fc42c
22 changed files with 280 additions and 192 deletions
@@ -2,51 +2,51 @@
namespace Toolkit.Foundation.Avalonia
{
public class ContentDialogHandler : NavigationRouteHandler<ContentDialog>
{
public override async void Receive(NavigationRouteRequest<ContentDialog> message)
{
if (message.Template is ContentDialog contentDialog)
{
async void HandleButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
ContentDialogButtonClickDeferral defferal = args.GetDeferral();
//public class ContentDialogHandler : NavigationRouteHandler<ContentDialog>
//{
// public override async void Receive(NavigationRouteRequest<ContentDialog> message)
// {
// if (message.Template is ContentDialog contentDialog)
// {
// async void HandleButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
// {
// ContentDialogButtonClickDeferral defferal = args.GetDeferral();
if (sender.DataContext is INavigationConfirmationAsync confirmationAsync)
{
if (!await confirmationAsync.CanConfirmAsync())
{
args.Cancel = true;
}
}
// if (sender.DataContext is INavigationConfirmationAsync confirmationAsync)
// {
// if (!await confirmationAsync.CanConfirmAsync())
// {
// args.Cancel = true;
// }
// }
if (sender.DataContext is INavigationConfirmation confirmation)
{
if (!confirmation.CanConfirm())
{
args.Cancel = true;
}
}
// if (sender.DataContext is INavigationConfirmation confirmation)
// {
// if (!confirmation.CanConfirm())
// {
// args.Cancel = true;
// }
// }
if (!args.Cancel)
{
contentDialog.SecondaryButtonClick -= HandleButtonClick;
contentDialog.PrimaryButtonClick -= HandleButtonClick;
contentDialog.CloseButtonClick -= HandleButtonClick;
}
// if (!args.Cancel)
// {
// contentDialog.SecondaryButtonClick -= HandleButtonClick;
// contentDialog.PrimaryButtonClick -= HandleButtonClick;
// contentDialog.CloseButtonClick -= HandleButtonClick;
// }
defferal.Complete();
}
// defferal.Complete();
// }
contentDialog.SecondaryButtonClick += HandleButtonClick;
contentDialog.PrimaryButtonClick += HandleButtonClick;
contentDialog.CloseButtonClick += HandleButtonClick;
// contentDialog.SecondaryButtonClick += HandleButtonClick;
// contentDialog.PrimaryButtonClick += HandleButtonClick;
// contentDialog.CloseButtonClick += HandleButtonClick;
contentDialog.DataContext = message.Data;
await contentDialog.ShowAsync();
// contentDialog.DataContext = message.Content;
// await contentDialog.ShowAsync();
message.Reply(true);
}
}
}
// message.Reply(true);
// }
// }
//}
}