//Called by EventHandlers in order to prevent invalid characters from being used in certain textboxes public static async void HandleValidatingBoxes(this TextBox textBox) { const string validChars = ".0123456789"; var messageDialogFactory = new MessageDialogFactory(); if (!textBox.Text.All(validChars.Contains)) { await messageDialogFactory.CreateDialog(textBox).ShowAsync(); } }
public static async void HandlePercentageHandlers(this TextBox textBox, TextBox boxToUpdate) { const string validChars = ".0123456789"; var messageDialogFactory = new MessageDialogFactory(); if (!textBox.Text.All(validChars.Contains)) { await messageDialogFactory.CreateDialog(textBox).ShowAsync(); } if (textBox.Text.Equals("")) { textBox.Text = "0"; } boxToUpdate.Text = textBox.AsOppositePercentage(); }