-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.xaml.cs
More file actions
39 lines (33 loc) · 1.11 KB
/
Copy pathApp.xaml.cs
File metadata and controls
39 lines (33 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System.Windows;
using GlassNotes.ViewModels;
namespace GlassNotes;
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
// Ensure the WPF framework uses the current culture for formatting UI elements
FrameworkElement.LanguageProperty.OverrideMetadata(
typeof(FrameworkElement),
new FrameworkPropertyMetadata(
System.Windows.Markup.XmlLanguage.GetLanguage(System.Globalization.CultureInfo.CurrentCulture.IetfLanguageTag)));
SessionEnding += App_SessionEnding;
base.OnStartup(e);
}
private void App_SessionEnding(object sender, SessionEndingCancelEventArgs e)
{
try
{
if (MainWindow is MainWindow mainWindow && mainWindow.DataContext is MainViewModel viewModel)
{
viewModel.Cleanup();
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"Error during session ending cleanup: {ex.Message}");
}
}
}