Esempio n. 1
0
        void RefreshItem(swc.TreeViewItem item)
        {
            if (item == null)
            {
                return;
            }
            var old = item.DataContext;

            item.DataContext = null;
            item.DataContext = old;

            item.InvalidateProperty(EtoTreeViewItem.IsExpandedProperty);
            item.HeaderTemplate = item.HeaderTemplate == template1 ? template2 : template1;
        }
        /// <summary>
        /// Called when an item is dragged over the TreeViewItem.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="System.Windows.DragEventArgs"/> instance containing the event data.</param>
        static void OnDragEvent(object sender, DragEventArgs args)
        {
            lock (IsPossibleDropTargetProperty)
            {
                _dropPossible = false;

                if (_currentItem != null)
                {
                    // Tell the item that previously had the mouse that it no longer does.
                    DependencyObject oldItem = _currentItem;
                    _currentItem = null;
                    oldItem.InvalidateProperty(IsPossibleDropTargetProperty);
                }

                if (args.Effects != DragDropEffects.None)
                {
                    _dropPossible = true;
                }

                TreeViewItem tvi = sender as TreeViewItem;
                if (tvi != null)
                {
                    _currentItem = tvi;
                    // Tell that item to re-calculate the IsPossibleDropTarget property
                    _currentItem.InvalidateProperty(IsPossibleDropTargetProperty);
                }
            }
        }
        //
        // OnUpdateOverItem:  This method is a listener for the UpdateOverItemEvent.  When it is received,
        // it means that the sender is the closest TreeViewItem to the mouse (closest in the sense of the
        // tree, not geographically).
        static void OnUpdateOverItem(object sender, RoutedEventArgs args)
        {
            // Mark this object as the tree view item over which the mouse
            // is currently positioned.
            _currentItem = sender as TreeViewItem;

            // Tell that item to re-calculate the IsMouseDirectlyOverItem property
            _currentItem.InvalidateProperty(IsMouseDirectlyOverItemProperty);

            // Prevent this event from notifying other tree view items higher in the tree.
            args.Handled = true;
        }
 private static void AquireItem(object sender)
 {
     var tvi = sender as TreeViewItem;
     if (tvi != null)
     {
         _currentItem = tvi;
         // Tell that item to re-calculate the IsPossibleDropTarget property
         _currentItem.InvalidateProperty(IsPossibleDropTargetProperty);
     }
 }