Created
April 26, 2022 02:46
-
-
Save hilapon/738b9c4b3d0b9492aae662d8ef67a406 to your computer and use it in GitHub Desktop.
CommunityToolkit.Mvvm での ViewModel サンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using CommunityToolkit.Mvvm.ComponentModel; | |
using CommunityToolkit.Mvvm.Input; | |
namespace MauiApp3 { | |
internal class MainViewModel : ObservableObject { | |
public RelayCommand IncrementCounterCommand { get; } | |
private int Counter; | |
public MainViewModel() { | |
CounterText = $"Current count: {Counter}"; | |
IncrementCounterCommand = new RelayCommand(() => CounterText = $"Current count: {++Counter}"); | |
} | |
private string _CounterText; | |
public string CounterText { | |
get => _CounterText; | |
set => SetProperty(ref _CounterText, value); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment