Exemplo n.º 1
0
 /// <summary>
 /// Returns true if the target node is a valid drop location.
 /// For this sample, a valid target node is the one that:
 ///     Represents an employee (departments are not valid)
 ///     Is not being copied to the same department it is assigned
 ///     Is not being moved to a department it is already assigned
 /// </summary>
 /// <param name="source"></param>
 /// <param name="target"></param>
 /// <returns></returns>
 private bool IsValidDrop(C1TreeViewItem source, C1TreeViewItem target)
 {
     bool isValidTarget = false;
     // For this sample we will allow dragging of employees only
     if ((source != null) && (target != null) && (source.Header is Employee) && (target.Header is Employee))
     {
         // Cannot copy employees in the same department
         Employee sourceDataObject = (Employee)source.Header;
         bool isAlreadyInDepartment = ((IList)target.ParentItemsSource).Contains(sourceDataObject);
         if ((isAlreadyInDepartment) && ((Effect == DragDropEffect.Copy) || (source.Parent != target.Parent)))
         {
             isValidTarget = false;
         }
         else
         {
             isValidTarget = (!source.IsAncestorOf(target) && !(source == target));
         }
     }
     return isValidTarget;
 }