Пример #1
0
		/// <summary>
		/// Initializes a new instance of the <see cref="AutoComplete"/> class.
		/// </summary>
		public AutoComplete( Control value )
		{
			InitializeComponent();

			this.controlUnderAutocomplete = ControlUnderAutoComplete.Create( value );

			this.viewSource = controlUnderAutocomplete.GetViewSource( ( Style )this[ this.controlUnderAutocomplete.StyleKey ] );
			this.viewSource.Filter += OnCollectionViewSourceFilter;

			this.controlUnderAutocomplete.Control.SetValue( Control.StyleProperty, this[ this.controlUnderAutocomplete.StyleKey ] );
			this.controlUnderAutocomplete.Control.ApplyTemplate();

			this.autoCompletePopup = ( Popup )this.controlUnderAutocomplete.Control.Template.FindName( "autoCompletePopup", this.controlUnderAutocomplete.Control );
			this._listBox = ( ListBox )this.controlUnderAutocomplete.Control.Template.FindName( "autoCompleteListBox", this.controlUnderAutocomplete.Control );

			var b = new Binding( "ActualWidth" )
			{
				UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
				Source = this.controlUnderAutocomplete.Control
			};

			this.ListBox.SetBinding( ListBox.MinWidthProperty, b );
			this.ListBox.PreviewMouseDown += OnListBoxPreviewMouseDown;

			this.controlUnderAutocomplete.Control.AddHandler( TextBox.TextChangedEvent, new TextChangedEventHandler( OnTextBoxTextChanged ) );
			this.controlUnderAutocomplete.Control.LostFocus += OnTextBoxLostFocus;
			this.controlUnderAutocomplete.Control.PreviewKeyUp += OnTextBoxPreviewKeyUp;
			this.controlUnderAutocomplete.Control.PreviewKeyDown += OnTextBoxPreviewKeyDown;
		}
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AutoComplete"/> class.
        /// </summary>
        public AutoComplete(Control value)
        {
            InitializeComponent();

            this.controlUnderAutocomplete = ControlUnderAutoComplete.Create(value);

            this.viewSource         = controlUnderAutocomplete.GetViewSource(( Style )this[this.controlUnderAutocomplete.StyleKey]);
            this.viewSource.Filter += OnCollectionViewSourceFilter;

            this.controlUnderAutocomplete.Control.SetValue(Control.StyleProperty, this[this.controlUnderAutocomplete.StyleKey]);
            this.controlUnderAutocomplete.Control.ApplyTemplate();

            this.autoCompletePopup = ( Popup )this.controlUnderAutocomplete.Control.Template.FindName("autoCompletePopup", this.controlUnderAutocomplete.Control);
            this._listBox          = ( ListBox )this.controlUnderAutocomplete.Control.Template.FindName("autoCompleteListBox", this.controlUnderAutocomplete.Control);

            var b = new Binding("ActualWidth")
            {
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
                Source = this.controlUnderAutocomplete.Control
            };

            this.ListBox.SetBinding(ListBox.MinWidthProperty, b);
            this.ListBox.PreviewMouseDown += OnListBoxPreviewMouseDown;

            this.controlUnderAutocomplete.Control.AddHandler(TextBox.TextChangedEvent, new TextChangedEventHandler(OnTextBoxTextChanged));
            this.controlUnderAutocomplete.Control.LostFocus      += OnTextBoxLostFocus;
            this.controlUnderAutocomplete.Control.PreviewKeyUp   += OnTextBoxPreviewKeyUp;
            this.controlUnderAutocomplete.Control.PreviewKeyDown += OnTextBoxPreviewKeyDown;
        }