Skip to content

Instantly share code, notes, and snippets.

@icebeam7
Created October 30, 2019 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icebeam7/9c9de2826ffabf79715668bf9efb5480 to your computer and use it in GitHub Desktop.
Save icebeam7/9c9de2826ffabf79715668bf9efb5480 to your computer and use it in GitHub Desktop.
AppDivisas: ConversorView.xaml.cs
using System;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace AppDivisas.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class ConversorView : ContentPage
{
const double tasa = 19.11;
public ConversorView()
{
InitializeComponent();
}
void Limpiar()
{
PesosEntry.Text = string.Empty;
DolaresLabel.Text = string.Empty;
}
private async void ConversorButton_Clicked(object sender, EventArgs e)
{
double pesos = 0, dolares = 0;
if (double.TryParse(PesosEntry.Text, out pesos))
{
dolares = pesos / tasa;
DolaresLabel.Text = $"{dolares:N2}";
}
else
{
await DisplayAlert("Error", "Cantidad no válida", "OK");
Limpiar();
}
}
private void LimpiarButton_Clicked(object sender, EventArgs e)
{
Limpiar();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment