From 0b4f405404d92e4e0d7cf79e68ecba58aefc1034 Mon Sep 17 00:00:00 2001 From: Russell Camo <32549126+russkyc@users.noreply.github.com> Date: Tue, 29 Aug 2023 15:51:25 +0800 Subject: [PATCH] fix: fixed main window not being focused on dialog closed Signed-off-by: Russell Camo <32549126+russkyc@users.noreply.github.com> --- .../ViewModels/AppointmentViewModel.cs | 1 + GroomWise.Application/ViewModels/CustomerViewModel.cs | 9 +++++++++ .../Views/Dialogs/AddAppointmentsView.xaml.cs | 9 +++++++++ GroomWise.WPF/Views/Dialogs/AddCustomersView.xaml.cs | 10 ++++++++++ .../Views/Templates/CustomerListCardTemplate.xaml | 8 +++++--- 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/GroomWise.Application/ViewModels/AppointmentViewModel.cs b/GroomWise.Application/ViewModels/AppointmentViewModel.cs index 8c8a7f2..f4399d8 100644 --- a/GroomWise.Application/ViewModels/AppointmentViewModel.cs +++ b/GroomWise.Application/ViewModels/AppointmentViewModel.cs @@ -100,4 +100,5 @@ await Task.Run(() => } }); } + } diff --git a/GroomWise.Application/ViewModels/CustomerViewModel.cs b/GroomWise.Application/ViewModels/CustomerViewModel.cs index 53f20f0..26f1a83 100644 --- a/GroomWise.Application/ViewModels/CustomerViewModel.cs +++ b/GroomWise.Application/ViewModels/CustomerViewModel.cs @@ -122,4 +122,13 @@ private async Task DeleteCustomer(object param) await Task.Run(() => GroomWiseDbContext.Customers.Delete(observableCustomer.Id)); } } + + [Command] + private async Task CloseDialogs() + { + await Task.Run(() => + { + DialogService.CloseDialogs(NavigationService); + }); + } } diff --git a/GroomWise.WPF/Views/Dialogs/AddAppointmentsView.xaml.cs b/GroomWise.WPF/Views/Dialogs/AddAppointmentsView.xaml.cs index 889c555..c28e10c 100644 --- a/GroomWise.WPF/Views/Dialogs/AddAppointmentsView.xaml.cs +++ b/GroomWise.WPF/Views/Dialogs/AddAppointmentsView.xaml.cs @@ -3,6 +3,8 @@ // Unauthorized copying or redistribution of all files, in source and binary forms via any medium // without written, signed consent from the author is strictly prohibited. +using System.ComponentModel; +using System.Linq; using GroomWise.Infrastructure.Navigation.Interfaces; namespace GroomWise.Views.Dialogs; @@ -14,4 +16,11 @@ public AddAppointmentsView(object viewModel) DataContext = viewModel; InitializeComponent(); } + + protected override void OnClosing(CancelEventArgs e) + { + var parent = App.Current.Windows.OfType().FirstOrDefault(); + parent.Focus(); + base.OnClosing(e); + } } diff --git a/GroomWise.WPF/Views/Dialogs/AddCustomersView.xaml.cs b/GroomWise.WPF/Views/Dialogs/AddCustomersView.xaml.cs index f494bbf..ed56ac4 100644 --- a/GroomWise.WPF/Views/Dialogs/AddCustomersView.xaml.cs +++ b/GroomWise.WPF/Views/Dialogs/AddCustomersView.xaml.cs @@ -3,6 +3,9 @@ // Unauthorized copying or redistribution of all files, in source and binary forms via any medium // without written, signed consent from the author is strictly prohibited. +using System.ComponentModel; +using System.Linq; + namespace GroomWise.Views.Dialogs; public partial class AddCustomersView @@ -12,4 +15,11 @@ public AddCustomersView(object vm) DataContext = vm; InitializeComponent(); } + + protected override void OnClosing(CancelEventArgs e) + { + var parent = App.Current.Windows.OfType().FirstOrDefault(); + parent.Focus(); + base.OnClosing(e); + } } diff --git a/GroomWise.WPF/Views/Templates/CustomerListCardTemplate.xaml b/GroomWise.WPF/Views/Templates/CustomerListCardTemplate.xaml index 9a515a7..61b7648 100644 --- a/GroomWise.WPF/Views/Templates/CustomerListCardTemplate.xaml +++ b/GroomWise.WPF/Views/Templates/CustomerListCardTemplate.xaml @@ -14,15 +14,17 @@ Background="Transparent" mc:Ignorable="d"> - + Text="{Binding FullName, UpdateSourceTrigger=PropertyChanged}" />