示例#1
0
        private static void OnIsSelectionEnabledPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            MyListBox myListBox = (MyListBox)obj;

            if ((bool)e.NewValue)
            {
                myListBox.OpenSelection();
            }
            else
            {
                myListBox.UnselectAll();
                myListBox.CloseSelection();
            }
        }
示例#2
0
        private static void OnMyItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            MyListBox myListBox = d as MyListBox;

            if (e.NewValue is INotifyCollectionChanged)
            {
                (e.NewValue as INotifyCollectionChanged).CollectionChanged += new NotifyCollectionChangedEventHandler(myListBox.MyListBox_CollectionChanged);
            }
            ObservableCollection <object> observableCollection = new ObservableCollection <object>();

            foreach (object obj in e.NewValue as IEnumerable)
            {
                observableCollection.Add(obj);
            }
            if (myListBox.SupportsFooter)
            {
                observableCollection.Add(myListBox.DataContext);
            }
            observableCollection.CollectionChanged += new NotifyCollectionChangedEventHandler(myListBox.itemsSource_CollectionChanged);
            myListBox.ItemsSource = (IEnumerable)observableCollection;
        }
示例#3
0
        private static void OnMyItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            MyListBox myListBox = d as MyListBox;

            // ISSUE: explicit reference operation
            if (e.NewValue is INotifyCollectionChanged)
            {
                // ISSUE: explicit reference operation
                (e.NewValue as INotifyCollectionChanged).CollectionChanged += new NotifyCollectionChangedEventHandler(myListBox.MyListBox_CollectionChanged);
            }
            ObservableCollection <object> observableCollection = new ObservableCollection <object>();

            // ISSUE: explicit reference operation
            foreach (object obj in e.NewValue as IEnumerable)
            {
                observableCollection.Add(obj);
            }
            if (myListBox.SupportsFooter)
            {
                observableCollection.Add(((FrameworkElement)myListBox).DataContext);
            }
            observableCollection.CollectionChanged += new NotifyCollectionChangedEventHandler(myListBox.itemsSource_CollectionChanged);
            ((ItemsControl)myListBox).ItemsSource   = ((IEnumerable)observableCollection);
        }
示例#4
0
 public override void OnApplyTemplate()
 {
     base.OnApplyTemplate();
     this._parent = this.FindParent();
     this.UpdateVisualState(false);
 }