HeadMeld 0.0.0.1
- Working MVVM implementation - Refactored code
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using HeadMeld.Models;
|
||||
|
||||
namespace HeadMeld.ViewModels
|
||||
{
|
||||
sealed class MainWindowViewModel : INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
protected void OnPropertyChange(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
|
||||
private MainWindowModel _model = new();
|
||||
|
||||
public bool ToggleAPOEnabled
|
||||
{
|
||||
get { return _model.ToggleAPOEnabled; }
|
||||
set
|
||||
{
|
||||
if (_model.ToggleAPOEnabled != value)
|
||||
{
|
||||
_model.ToggleAPOEnabled = value;
|
||||
OnPropertyChange(nameof(ToggleAPOEnabled));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<string> Profiles
|
||||
{
|
||||
get { return _model.Profiles; }
|
||||
set
|
||||
{
|
||||
if (_model.Profiles != value)
|
||||
{
|
||||
_model.Profiles = value;
|
||||
OnPropertyChange(nameof(Profiles));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MainWindowViewModel()
|
||||
{
|
||||
_model = new()
|
||||
{
|
||||
ToggleAPOEnabled = true,
|
||||
Profiles = new List<string>() { "1", "2"}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user