You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
MyFirstMAUI/MyFirstMauiApp/SharedResources/StandardTipPage.xaml.cs

45 lines
1.1 KiB

using Color = Microsoft.Maui.Graphics.Color;
namespace SharedResources;
public partial class StandardTipPage : ContentPage
{
private Color colorNavy = Colors.Navy;
private Color colorSilver = Colors.Silver;
public StandardTipPage()
{
InitializeComponent();
billInput.TextChanged += (s, e) => CalculateTip();
}
private void CalculateTip()
{
double bill;
if (Double.TryParse(billInput.Text, out bill) && bill > 0)
{
double tip = Math.Round(bill * 0.15, 2);
double final = bill + tip;
tipOutput.Text = tip.ToString("C");
totalOutput.Text = final.ToString("C");
}
}
private void OnLight(object sender, EventArgs e)
{
Resources["fgColor"] = colorNavy;
Resources["bgColor"] = colorSilver;
}
private void OnDark(object sender, EventArgs e)
{
Resources["fgColor"] = colorSilver;
Resources["bgColor"] = colorNavy;
}
private async void GotoCustom(object sender, EventArgs e)
{
await Shell.Current.GoToAsync(nameof(CustomTipPage));
}
}