Created
October 30, 2019 22:12
-
-
Save icebeam7/9c9de2826ffabf79715668bf9efb5480 to your computer and use it in GitHub Desktop.
AppDivisas: ConversorView.xaml.cs
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 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