Adding point works
This commit is contained in:
@@ -1,6 +1,40 @@
|
||||
namespace GazpromApp.ViewModels;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace GazpromApp.ViewModels;
|
||||
using GazpromApp.Messages;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
public partial class MainWindowViewModel : ViewModelBase
|
||||
{
|
||||
public string Greeting { get; } = "Welcome to Avalonia!";
|
||||
public ObservableCollection<PointViewModel> Points { get; } = new ObservableCollection<PointViewModel>();
|
||||
|
||||
[RelayCommand]
|
||||
private async Task AddPoint()
|
||||
{
|
||||
var point = await WeakReferenceMessenger.Default.Send(new NewPointMessage());
|
||||
if (point != null)
|
||||
Points.Add(point);
|
||||
IsLineVisible = true;
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void RemovePoint(PointViewModel point)
|
||||
{
|
||||
Points.Remove(point);
|
||||
if (Points.Count == 0)
|
||||
IsLineVisible = false;
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void EditPoint(PointViewModel point)
|
||||
{
|
||||
Debug.WriteLine(point.Name);
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _isLineVisible;
|
||||
}
|
||||
Reference in New Issue
Block a user