forked from verybadcat/CSharpMath
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainView.xaml.cs
More file actions
30 lines (27 loc) · 954 Bytes
/
MainView.xaml.cs
File metadata and controls
30 lines (27 loc) · 954 Bytes
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
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Styling;
namespace CSharpMath.Avalonia.Example {
public class MainView : UserControl {
public MainView() {
InitializeComponent();
var light = this.Find<RadioButton>("lightThemeRbn")!;
var dark = this.Find<RadioButton>("darkThemeRbn")!;
if ((string)Application.Current!.ActualThemeVariant.Key == "Dark")
dark.IsChecked = true;
else light.IsChecked = true;
light.IsCheckedChanged += (sender, e) => {
Application.Current!.RequestedThemeVariant =
light.IsChecked == true ? ThemeVariant.Light : ThemeVariant.Dark;
};
dark.IsCheckedChanged += (sender, e) => {
Application.Current!.RequestedThemeVariant =
dark.IsChecked == false ? ThemeVariant.Light : ThemeVariant.Dark;
};
}
private void InitializeComponent() {
AvaloniaXamlLoader.Load(this);
}
}
}