public static void RefreshContextMenu(this IDataUi dataUi, ContextMenu contextMenu) { RoutedEventHandler makeDefaultHandler = (sender, e) => { dataUi.InstanceMember.IsDefault = true; dataUi.Refresh(); // the instance member may have undone the IsDefault, so let's only do this if it's still set to default: if (dataUi is ISetDefaultable && dataUi.InstanceMember.IsDefault) { ((ISetDefaultable)dataUi).SetToDefault(); } }; contextMenu.Items.Clear(); AddContextMenuItem("Make Default", makeDefaultHandler, contextMenu); if (dataUi.InstanceMember != null) { foreach (var kvp in dataUi.InstanceMember.ContextMenuEvents) { AddContextMenuItem(kvp.Key, kvp.Value, contextMenu).Tag = dataUi.InstanceMember; } } }
public static void RefreshContextMenu(this IDataUi dataUi, ContextMenu contextMenu) { RoutedEventHandler makeDefaultHandler = (sender, e) => { dataUi.InstanceMember.IsDefault = true; dataUi.Refresh(); if (dataUi is ISetDefaultable) { ((ISetDefaultable)dataUi).SetToDefault(); } }; contextMenu.Items.Clear(); AddContextMenuItem("Make Default", makeDefaultHandler, contextMenu); if (dataUi.InstanceMember != null) { foreach (var kvp in dataUi.InstanceMember.ContextMenuEvents) { AddContextMenuItem(kvp.Key, kvp.Value, contextMenu).Tag = dataUi.InstanceMember; } } }
private void HandlePreviewKeydown(object sender, System.Windows.Input.KeyEventArgs e) { if (e.Key == Key.Enter && (HandlesEnter)) { e.Handled = true; ClampTextBoxValuesToMinMax(); var result = TryApplyToInstance(); TextAtStartOfEditing = mAssociatedTextBox.Text; if (result == ApplyValueResult.Success) { mContainer.Refresh(forceRefreshEvenIfFocused: true); } } else if (e.Key == Key.Escape) { HasUserChangedAnything = false; mAssociatedTextBox.Text = TextAtStartOfEditing; } }