В курсе есть событие клика для вызова OnCall > это выглядит так
Код: Выделить всё
private async void OnCall(object sender, EventArgs e)
{
var confirmCall = DisplayAlert(
"Dial a Number",
$"Would you like to call {translatedNumber}?",
"Yes",
"No"
);
if (await confirmCall)
{
try
{
PhoneDialer.Open(translatedNumber);
}
catch (ArgumentNullException)
{
await DisplayAlert("Unable to dial", "Phone number was not valid.", "OK");
}
catch (FeatureNotSupportedException)
{
await DisplayAlert("Unable to dial", "Phone dialing not supported.", "OK");
}
catch (Exception)
{
await DisplayAlert("Unable to dial", "Phone dialing failed.", "OK");
}
}
}
Код: Выделить всё
[ICommand]
public async void OnCall ()
{
var confirmCall = DisplayAlert(
"Dial a Number",
$"Would you like to call {translatedNumber}?",
"Yes",
"No"
);
if (await confirmCall)
{
try
{
PhoneDialer.Open(translatedNumber);
}
catch (ArgumentNullException)
{
await DisplayAlert("Unable to dial", "Phone number was not valid.", "OK");
}
catch (FeatureNotSupportedException)
{
await DisplayAlert("Unable to dial", "Phone dialing not supported.", "OK");
}
catch (Exception)
{
await DisplayAlert("Unable to dial", "Phone dialing failed.", "OK");
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/724 ... -viewmodel