Skip to content

Instantly share code, notes, and snippets.

@TBertuzzi
Created July 28, 2021 00:50
Show Gist options
  • Save TBertuzzi/1d9abac3a36f64bd73bd14b8815cf628 to your computer and use it in GitHub Desktop.
Save TBertuzzi/1d9abac3a36f64bd73bd14b8815cf628 to your computer and use it in GitHub Desktop.
using System;
using System.Threading.Tasks;
using MvvmHelpers;
using XamarinFormsEventAggregator.Events;
namespace XamarinFormsEventAggregator.ViewModels
{
public class SomarViewModel : BaseViewModel
{
private readonly IEventAggregator _EventAggregator;
public MvvmHelpers.Commands.Command SomarCommand { get; }
int _cont = 0;
string _texto;
public string Texto
{
get
{
return _texto;
}
set
{
SetProperty(ref _texto, value);
}
}
public SomarViewModel()
{
_texto = "Soma 0";
SomarCommand = new MvvmHelpers.Commands.Command(async () => await SomarCommandExecute());
}
private async Task SomarCommandExecute()
{
_cont++;
var texto = $"Soma {_cont}";
Texto = texto;
var SomarMessage = new SomarMessage
{
Texto = texto
};
EventAggregator.Instance.SendMessage(SomarMessage);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment