コード例 #1
0
        protected override void OnSelectedItemChanged(RoutedPropertyChangedEventArgs <object> e)
        {
            if (e.NewValue != null)
            {
                _selectItem = e.NewValue as TreeDateDemo;
            }
            else if (e.OldValue != null)
            {
                _selectItem = e.OldValue as TreeDateDemo;
            }
            else
            {
                _selectItem = null;
            }


            this.SelectText = _selectItem.Header;
            foreach (var item in _coll)
            {
                if (item != _selectItem)
                {
                    item.IsMouseLeftDown = true;
                }
            }
            base.OnSelectedItemChanged(e);
        }
コード例 #2
0
        protected override void OnMouseLeave(MouseEventArgs e)
        {
            if (_selectItem != null)
            {
                _selectItem.IsSelected = false;
                this._selectItem       = null;
            }
            _moveSnapshoot.Visibility = Visibility.Collapsed;

            base.OnMouseLeave(e);
        }
コード例 #3
0
 protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
 {
     if (this._moveSnapshoot.Visibility == Visibility.Visible)
     {
         this._moveSnapshoot.Visibility = Visibility.Collapsed;
         _selectItem.IsExpanded         = false;
         FrameworkElement viewItem = Mouse.DirectlyOver as FrameworkElement;
         TreeViewItem     it       = null;
         GetItemView(viewItem, ref it);
         if (it == null)
         {
             return;
         }
         TreeDateDemo target = it.DataContext as TreeDateDemo;
         if (target != null && target != _selectItem)
         {
             int odleIndex = _coll.IndexOf(_selectItem);
             int newIndex  = _coll.IndexOf(target);
             _coll.Move(odleIndex, newIndex);
         }
         foreach (var item in _coll)
         {
             item.IsMouseLeftDown = false;
         }
     }
     else
     {
         if (_selectItem.IsExpanded)
         {
             _selectItem.IsExpanded = false;
         }
         else
         {
             _selectItem.IsExpanded = true;
         }
     }
     base.OnMouseLeftButtonUp(e);
 }