Esempio n. 1
0
 private void ItemsSource_PropertyChanged(DependencyObject sender, DependencyProperty dp)
 {
     // If we're given a different ItemsSource, we need to wrap that collection in our helper class.
     if (ItemsSource != null && ItemsSource.GetType() != typeof(InterspersedObservableCollection))
     {
         _innerItemsSource = new InterspersedObservableCollection(ItemsSource);
         _currentTextEdit  = _lastTextEdit = new PretokenStringContainer();
         _innerItemsSource.Insert(_innerItemsSource.Count, _currentTextEdit);
         ItemsSource = _innerItemsSource;
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="TokenizingTextBox"/> class.
        /// </summary>
        public TokenizingTextBox()
        {
            // Setup our base state of our collection
            _innerItemsSource = new InterspersedObservableCollection(new ObservableCollection <object>()); // TODO: Test this still will let us bind to ItemsSource in XAML?
            _currentTextEdit  = _lastTextEdit = new PretokenStringContainer(true);
            _innerItemsSource.Insert(_innerItemsSource.Count, _currentTextEdit);
            ItemsSource = _innerItemsSource;
            //// TODO: Consolidate with callback below for ItemsSourceProperty changed?

            DefaultStyleKey = typeof(TokenizingTextBox);

            // TODO: Do we want to support ItemsSource better? Need to investigate how that works with adding...
            RegisterPropertyChangedCallback(ItemsSourceProperty, ItemsSource_PropertyChanged);
            PreviewKeyDown    += TokenizingTextBox_PreviewKeyDown;
            PreviewKeyUp      += TokenizingTextBox_PreviewKeyUp;
            CharacterReceived += TokenizingTextBox_CharacterReceived;
            ItemClick         += TokenizingTextBox_ItemClick;
        }
Esempio n. 3
0
        private void UpdateCurrentTextEdit(PretokenStringContainer edit)
        {
            _currentTextEdit = edit;

            Text = edit.Text; // Update our text property.
        }