First real stable push since migrating
This commit is contained in:
36
LD-SysInfo/MainWindowViewModel.cs
Normal file
36
LD-SysInfo/MainWindowViewModel.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
namespace LD_SysInfo;
|
||||
|
||||
public partial class MainWindowViewModel : ObservableObject
|
||||
{
|
||||
//This is using the source generators from CommunityToolkit.Mvvm to generate a RelayCommand
|
||||
//See: https://learn.microsoft.com/dotnet/communitytoolkit/mvvm/generators/observableproperty
|
||||
//and: https://learn.microsoft.com/windows/communitytoolkit/mvvm/observableobject
|
||||
[ObservableProperty]
|
||||
[NotifyCanExecuteChangedFor(nameof(IncrementCountCommand))]
|
||||
private int _count;
|
||||
|
||||
public MainWindowViewModel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//This is using the source generators from CommunityToolkit.Mvvm to generate a RelayCommand
|
||||
//See: https://learn.microsoft.com/dotnet/communitytoolkit/mvvm/generators/relaycommand
|
||||
//and: https://learn.microsoft.com/windows/communitytoolkit/mvvm/relaycommand
|
||||
[RelayCommand(CanExecute = nameof(CanIncrementCount))]
|
||||
private void IncrementCount()
|
||||
{
|
||||
Count++;
|
||||
}
|
||||
|
||||
private bool CanIncrementCount() => Count < 5;
|
||||
|
||||
[RelayCommand]
|
||||
private void ClearCount()
|
||||
{
|
||||
Count = 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user