Created
July 28, 2021 00:50
-
-
Save TBertuzzi/1d9abac3a36f64bd73bd14b8815cf628 to your computer and use it in GitHub Desktop.
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 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