39 lines
970 B
C#
39 lines
970 B
C#
using Avalonia.Controls;
|
|
using Avalonia.Interactivity;
|
|
using Avalonia.Markup.Xaml;
|
|
using EinmaleinsTrainer.ViewModels;
|
|
|
|
namespace EinmaleinsTrainer.Views;
|
|
|
|
public partial class MainView : UserControl
|
|
{
|
|
public MainView()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void InitializeComponent()
|
|
{
|
|
AvaloniaXamlLoader.Load(this);
|
|
}
|
|
|
|
private void Row_Checked(object sender, RoutedEventArgs e)
|
|
{
|
|
if (sender is CheckBox cb
|
|
&& DataContext is MainViewModel vm
|
|
&& int.TryParse(cb.Content?.ToString(), out int value))
|
|
{
|
|
vm.ToggleRow(value, true);
|
|
}
|
|
}
|
|
|
|
private void Row_Unchecked(object sender, RoutedEventArgs e)
|
|
{
|
|
if (sender is CheckBox cb
|
|
&& DataContext is MainViewModel vm
|
|
&& int.TryParse(cb.Content?.ToString(), out int value))
|
|
{
|
|
vm.ToggleRow(value, false);
|
|
}
|
|
}
|
|
} |