From 21aad617a2e7859f1f56cd8aca064bd977747fbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miskolczi=20Rich=C3=A1rd?= Date: Sun, 5 May 2024 18:25:18 +0200 Subject: [PATCH] added create method in mainwindow code-behind --- .../MainWindow.xaml.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/WD7UVN_SzTGUI_2023242.Client.WPF/MainWindow.xaml.cs b/WD7UVN_SzTGUI_2023242.Client.WPF/MainWindow.xaml.cs index e94c515..8c2d885 100644 --- a/WD7UVN_SzTGUI_2023242.Client.WPF/MainWindow.xaml.cs +++ b/WD7UVN_SzTGUI_2023242.Client.WPF/MainWindow.xaml.cs @@ -1,4 +1,5 @@ using System.Windows; +using WD7UVN_SzTGUI_2023242.Client.WPF.ViewModels; using WD7UVN_SzTGUI_2023242.Client.WPF.Windows; namespace WD7UVN_SzTGUI_2023242.Client.WPF @@ -36,5 +37,23 @@ namespace WD7UVN_SzTGUI_2023242.Client.WPF Window window = new GetAllMaintainerTeams(); window.Show(); } + + private void CreateNewCustomer(object sender, RoutedEventArgs e) + { + CreateNewCustomerViewModel viewModel = new CreateNewCustomerViewModel(); + viewModel.NewCustomerCreated += (newCustomer) => + { + var getAllCustomersViewModel = (GetAllCustomersViewModel)DataContext; + if (getAllCustomersViewModel != null) + { + Application.Current.Dispatcher.Invoke(() => + { + getAllCustomersViewModel.Customers.Add(newCustomer); + }); + } + }; + Window window = new CreateNewCustomer(viewModel); + window.Show(); + } } }