Skip to content

Commit

Permalink
fix: fixed main window not being focused on dialog closed
Browse files Browse the repository at this point in the history
Signed-off-by: Russell Camo <[email protected]>
  • Loading branch information
russkyc committed Aug 29, 2023
1 parent f2762a4 commit 0b4f405
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
1 change: 1 addition & 0 deletions GroomWise.Application/ViewModels/AppointmentViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,5 @@ private async Task SaveAppointment()
}
});
}

}
9 changes: 9 additions & 0 deletions GroomWise.Application/ViewModels/CustomerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
}
9 changes: 9 additions & 0 deletions GroomWise.WPF/Views/Dialogs/AddAppointmentsView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -14,4 +16,11 @@ public AddAppointmentsView(object viewModel)
DataContext = viewModel;
InitializeComponent();
}

protected override void OnClosing(CancelEventArgs e)
{
var parent = App.Current.Windows.OfType<MainView>().FirstOrDefault();
parent.Focus();
base.OnClosing(e);
}
}
10 changes: 10 additions & 0 deletions GroomWise.WPF/Views/Dialogs/AddCustomersView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -12,4 +15,11 @@ public AddCustomersView(object vm)
DataContext = vm;
InitializeComponent();
}

protected override void OnClosing(CancelEventArgs e)
{
var parent = App.Current.Windows.OfType<MainView>().FirstOrDefault();
parent.Focus();
base.OnClosing(e);
}
}
8 changes: 5 additions & 3 deletions GroomWise.WPF/Views/Templates/CustomerListCardTemplate.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@
Background="Transparent"
mc:Ignorable="d">
<Grid Style="{StaticResource FadeInFromBottomAnimation}">
<russkyc:ModernButton
<russkyc:ModernRadioButton
x:Name="CardButton"
Padding="5"
HorizontalContentAlignment="Stretch"
CheckedBackground="{DynamicResource bg-200}"
Command="{Binding DataContext.GetCustomerInfoCommand, RelativeSource={RelativeSource FindAncestor, AncestorType=pages:CustomersView}}"
CommandParameter="{Binding}"
CornerRadius="10"
DefaultBackground="{DynamicResource bg-100}"
DefaultBackground="{DynamicResource bg-000}"
DefaultForeground="{DynamicResource fg-000}"
GroupName="CustomerListGroup"
HoverBackground="{DynamicResource bg-100}"
HoverForeground="{DynamicResource fg-000}"
PressedBackground="{DynamicResource bg-200}"
Expand All @@ -49,7 +51,7 @@
VerticalAlignment="Center"
FontSize="14"
FontWeight="Medium"
Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}" />
Text="{Binding FullName, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock
Grid.Column="2"
Margin="12,0,0,0"
Expand Down

0 comments on commit 0b4f405

Please sign in to comment.