// event handlers private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { // make sure name and unit are not empty string if (string.IsNullOrWhiteSpace(TextBoxName.Text)) { FlyoutWarmingText.Text = "Name cannot be empty!"; FlyoutWarming.ShowAt(TextBoxName); args.Cancel = true; return; } if (ComboBoxCategory.SelectedIndex == -1) { FlyoutWarmingText.Text = "Category cannot be empty!"; FlyoutWarming.ShowAt(ComboBoxCategory); args.Cancel = true; return; } if (ComboBoxUnit.SelectedIndex == -1) { FlyoutWarmingText.Text = "Unit cannot be empty!"; FlyoutWarming.ShowAt(ComboBoxUnit); args.Cancel = true; return; } // perform real update TextBoxName.GetBindingExpression(TextBox.TextProperty).UpdateSource(); ComboBoxCategory.GetBindingExpression(ComboBox.SelectedValueProperty).UpdateSource(); ComboBoxUnit.GetBindingExpression(ComboBox.SelectedValueProperty).UpdateSource(); ImageThumbnail.GetBindingExpression(Image.SourceProperty).UpdateSource(); this.ingredient.ThumbnailFilename = this.thumbnailFilename; }
protected override void OnClosing(CancelEventArgs e) { TextBoxName.GetBindingExpression(TextBox.TextProperty).UpdateSource(); bool hasError = (bool)TextBoxName.GetValue(Validation.HasErrorProperty); if (this.DialogResult == true && hasError) { MessageBox.Show("There are still errors, cannot close"); e.Cancel = true; } }
private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { // make sure name and unit are not empty string if (string.IsNullOrWhiteSpace(TextBoxName.Text)) { FlyoutWarmingText.Text = "Name cannot be empty!"; FlyoutWarming.ShowAt(TextBoxName); args.Cancel = true; return; } // perform real update TextBoxName.GetBindingExpression(TextBox.TextProperty).UpdateSource(); }
public Dialog() { InitializeComponent(); this.DataContext = this; TextBoxName.GetBindingExpression(TextBox.TextProperty).UpdateSource(); }