private void RegisterRevealButtonEvent() { _revealButton.AddHandler(UIElement.MouseLeftButtonDownEvent, (MouseButtonEventHandler)OnRevealButtonPointerPressed, true); _revealButton.AddHandler(UIElement.MouseLeftButtonUpEvent, (MouseButtonEventHandler)OnRevealButtonPointerReleased, true); _revealButton.AddHandler(UIElement.MouseEnterEvent, (RoutedEventHandler)OnRevealButtonPointerEnter, true); }
/// <summary> /// Registers this object to receive notifications of changes to the content. /// </summary> /// <param name="dependencyObject">The target element that will register for state change events.</param> public override void Register(DependencyObject dependencyObject) { // The Undo/Redo strategy involves handling global operations that are common to all controls and specific operations // that are particular to a family of controls. This registers handlers for this family of controls that will add the // proper actions to the Undo/Redo stacks. ToggleButton toggleButton = dependencyObject as ToggleButton; toggleButton.AddHandler(ToggleButton.CheckedEvent, new RoutedEventHandler(CheckedHandler), true); toggleButton.AddHandler(ToggleButton.UncheckedEvent, new RoutedEventHandler(CheckedHandler), true); toggleButton.AddHandler(FrameworkElement.PreviewKeyDownEvent, new KeyEventHandler(KeyDownHandler)); }
private static void UncheckedRadioButtonEvent(Object sender, RoutedEventArgs e) { ToggleButton button = (ToggleButton)sender; button.RemoveHandler( RadioButton.ClickEvent, UncheckedRadioButtonEventHandler); button.AddHandler( RadioButton.ClickEvent, CheckedRadioButtonEventHandler); button.IsChecked = true; }
/// <summary> /// Responsible for generating both modal and non modal /// enumerated UI components. /// </summary> /// <param name="agg"></param> /// <returns></returns> private UIElement genEnumerationSelector(Aggregate agg) { //gen base ui elements. StackPanel stk = new StackPanel(); ComboBox cbx = new ComboBox(); UniformGrid grd = new UniformGrid(); Label lbl = new Label(); lbl.Content = agg.name; //determine the nature of modallity. bool modal = true; for (int i = 0; i < agg.aggregation.Count; i++) { //why is the C# for iterator const? Its annoying... var item = agg.aggregation[i]; //mutal exclusion in this case means all other options should be //deselected if this one is choosen. i.e. AllFlags and NoFlags //are a direct contradiction. //modality is whether ALL options are mutually exclusive. if (item.name == "AllFlags") { modal = false; item.isMutuallyExclusive = true; } else if (item.name == "NoFlags") { item.isMutuallyExclusive = true; } } //add to compositor. stk.Children.Add(lbl); //deal with modality. if (modal) { //for modal, generate a list of mutually exclusive //options, i.e only one may be set. foreach (var item in agg.aggregation) { cbx.Items.Add(item.name); } //add to compositor. stk.Children.Add(cbx); //generate event aggregate mappings, and event callbacks. mUIToAggregation.Add(cbx, agg); cbx.AddHandler(ComboBox.SelectionChangedEvent, new RoutedEventHandler(onSingleSelect)); //select default. cbx.SelectedIndex = 0; } else { List <ToggleButton> tbnList = new List <ToggleButton>(); foreach (var item in agg.aggregation) { ToggleButton btn = new ToggleButton(); btn.Content = item.name; grd.Children.Add(btn); tbnList.Add(btn); //generate event aggregate mappings, and event callbacks. //(this is per button) mUIToAggregation.Add(btn, agg); btn.AddHandler(Button.ClickEvent, new RoutedEventHandler(onMultiSelect)); } //select default. tbnList[0].IsChecked = true; stk.Children.Add(grd); } return(stk); }