24 lines
586 B
C#
24 lines
586 B
C#
using Avalonia;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Interactivity;
|
|
using Avalonia.Styling;
|
|
|
|
namespace Semi.Avalonia.Demo.Views;
|
|
|
|
public partial class MainView : UserControl
|
|
{
|
|
public MainView()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void ToggleButton_OnIsCheckedChanged(object sender, RoutedEventArgs e)
|
|
{
|
|
var app = Application.Current;
|
|
if (app is not null)
|
|
{
|
|
var theme = app.ActualThemeVariant;
|
|
app.RequestedThemeVariant = theme == ThemeVariant.Dark ? ThemeVariant.Light : ThemeVariant.Dark;
|
|
}
|
|
}
|
|
} |