コード例 #1
0
        /// <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.
            Selector selector = dependencyObject as Selector;

            selector.AddHandler(Selector.SelectionChangedEvent, new SelectionChangedEventHandler(HandleSelectionChanged), true);
            selector.AddHandler(FrameworkElement.PreviewKeyDownEvent, new KeyEventHandler(HandleKeyDown));
        }
コード例 #2
0
        private static void OnWatermarkTextChanged(
            DependencyObject dependencyObject,
            DependencyPropertyChangedEventArgs e
            )
        {
            EnsureCorrectControl(dependencyObject);
            Control control = dependencyObject as Control;

            if (control != null)
            {
                SetWatermarkVisibility(control);
                control.RemoveHandler(
                    TextBoxBase.TextChangedEvent,
                    new TextChangedEventHandler(OnTextChanged)
                    );
                control.AddHandler(
                    TextBoxBase.TextChangedEvent,
                    new TextChangedEventHandler(OnTextChanged),
                    true
                    );
                Selector selector = control as Selector;
                if (selector != null)
                {
                    selector.AddHandler(Selector.SelectionChangedEvent,
                                        new SelectionChangedEventHandler(OnSelectionChanged)
                                        );
                }
            }
        }
コード例 #3
0
 public override void OnApplyTemplate()
 {
     base.OnApplyTemplate();
     _suggenstionListBox = this.GetTemplateChild("PART_SuggenstionListBox") as Selector;
     if (_suggenstionListBox != null)
     {
         _suggenstionListBox.AddHandler(ListBox.PreviewKeyDownEvent, new KeyEventHandler(this.OnSuggestionListBoxPreviewKeyDown));
         _suggenstionListBox.AddHandler(ListBox.MouseUpEvent, new MouseButtonEventHandler(this.OnSuggestionListBoxMouseUp));
         _suggenstionListBox.AddHandler(ListBox.LostFocusEvent, new RoutedEventHandler(this.OnSuggestionListBoxLostFocus));
     }
     _popup        = this.GetTemplateChild("PART_Popup") as Popup;
     _searchButton = this.GetTemplateChild("PART_SearchButton") as Button;
     if (_searchButton != null)
     {
         _searchButton.AddHandler(Button.ClickEvent, new RoutedEventHandler(this.OnSearchButtonClick));
         this.InvalidateMeasure();
         this.Measure(new Size(100, 100));
         _searchButton.Height = this.DesiredSize.Height;
     }
     this.AddHandler(SearchBox.SizeChangedEvent, new SizeChangedEventHandler(this.OnSizeChanged));
 }
コード例 #4
0
 /// <summary>
 /// Constructs a new selector property binding for the given Selector element.
 /// </summary>
 /// <param name="selector">The selector element to be bound to the data property.</param>
 protected SelectorPropertyBinding(Selector selector) : base(selector)
 {
     selector.SelectionChanged += OnSelectionChanged;
     selector.AddHandler(TextBoxBase.TextChangedEvent, new TextChangedEventHandler(OnTextChanged));
 }