-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMainWindow.xaml.cs
More file actions
46 lines (43 loc) · 1.67 KB
/
Copy pathMainWindow.xaml.cs
File metadata and controls
46 lines (43 loc) · 1.67 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
39
40
41
42
43
44
45
46
using MultiTools.Pages;
using System.Windows;
using Wpf.Ui.Controls;
namespace MultiTools
{
public partial class MainWindow : Window
{
public MainWindow(NavigationPageModel model)
{
InitializeComponent();
DataContext = model;
Loaded += (_, _) => Dash.Navigate(typeof(DashWindow));
// Ensure navigationView (Dash) is properly initialized before attaching the event handler
this.Loaded += (s, e) =>
{
if (Dash != null)
{
Dash.SelectionChanged += OnNavigationViewSelectionChanged;
}
else
{
// Handle the null case appropriately, e.g., log an error or throw an exception
System.Windows.MessageBox.Show("NavigationView 'Dash' is not initialized.", "Error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
}
};
}
private void OnNavigationViewSelectionChanged(object sender, RoutedEventArgs e)
{
if (Dash.SelectedItem is NavigationViewItem selectedItem)
{
switch (selectedItem.Tag)
{
case "HomePage":
MainFrame.Navigate(new System.Uri("Pages/Dash.xaml", System.UriKind.Relative));
break;
case "InstallationPage":
MainFrame.Navigate(new System.Uri("Pages/Installation.xaml", System.UriKind.Relative));
break;
}
}
}
}
}