//add a new tag from the context menu and then apply it to the selected instruments private async void NewTagTextBox_KeyDown(object sender, KeyEventArgs e) { if (e.Key != Key.Enter) { return; } var newTagTextBox = (TextBox)sender; string newTagName = newTagTextBox.Text; //add the tag var addTagResult = await _client.AddTag(new Tag() { Name = newTagName }).ConfigureAwait(true); if (!addTagResult.WasSuccessful) { await this.ShowMessageAsync("Error", "Could not add tag").ConfigureAwait(true); return; } var newTag = addTagResult.Result; //apply the tag to the selected instruments var selectedInstruments = InstrumentsGrid.SelectedItems.Cast <Instrument>(); foreach (Instrument i in selectedInstruments) { i.Tags.Add(newTag); await _client.UpdateInstrument(i).ConfigureAwait(true); } //update the tag menu var allTags = await _client.GetTags().ConfigureAwait(true); if (allTags.WasSuccessful) { BuildTagContextMenu(allTags.Result); } newTagTextBox.Text = ""; CollectionViewSource.GetDefaultView(InstrumentsGrid.ItemsSource).Refresh(); }