public void HandleBehaviorDragDropEvents()
        {
            DragDropBehavior listBoxBehavior = behaviorManager1.GetBehavior <DragDropBehavior>(this.listBoxControl1);

            listBoxBehavior.DragOver += ListBoxBehavior_DragOver;
            listBoxBehavior.DragDrop += ListBoxBehavior_DragDrop;
        }
        public void HandleBehaviorDragDropEvents()
        {
            DragDropBehavior gridControlBehavior = behaviorManager1.GetBehavior <DragDropBehavior>(this.gridView1);

            gridControlBehavior.DragDrop += Behavior_DragDrop;
            gridControlBehavior.DragOver += Behavior_DragOver;
        }
Esempio n. 3
0
        /// <summary>
        /// Deattachs the behavior from the element.
        /// </summary>
        /// <param name="element">The element to deattach the behavior.</param>
        private static void DestroyBehavior(UIElement element)
        {
            DragDropBehavior behavior = element.GetValue(DragDropBehaviorProperty) as DragDropBehavior;

            if (behavior != null)
            {
                element.SetValue(DragDropBehaviorProperty, null);
                behavior.Dispose();
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Gets or creates a <see cref="DragDropBehavior"/> for the element.
        /// </summary>
        /// <param name="element">The element to attach the behavior.</param>
        /// <returns>The attached behavior.</returns>
        private static DragDropBehavior GetOrCreateBehavior(UIElement element)
        {
            DragDropBehavior behavior = element.GetValue(DragDropBehaviorProperty) as DragDropBehavior;

            if (behavior == null)
            {
                behavior = new DragDropBehavior(element);
                element.SetValue(DragDropBehaviorProperty, behavior);
            }

            return(behavior);
        }
 private Action <DragDropBehavior> MyBehaviorSettings()
 {
     return(behavior =>
     {
         behavior.Properties.AllowDrop = true;
         behavior.Properties.InsertIndicatorVisible = true;
         behavior.Properties.PreviewVisible = true;
         behavior.DragOver += Behavior_DragOver;
         behavior.DragDrop += Behavior_DragDrop;
         behavior.BeginDragDrop += Behavior_BeginDragDrop;
         behaviorField = behavior; // so we can release the events later
     });
 }
Esempio n. 6
0
        public DocumentNavigationPane()
        {
            myNodeFactory = new NavigationNodeFactory(OnSelectionChanged);
            Root          = new NavigationNode(myNodeFactory);

            CreateChildCommand = new DelegateCommand <NavigationNode>(OnCreateChild);
            DeleteCommand      = new DelegateCommand <NavigationNode>(n => ((NavigationNode)n.Parent).Children.Remove(n));

            var dragDropBehavior = new DragDropBehavior(Root);

            DropCommand = new DelegateCommand <NodeDropRequest>(dragDropBehavior.ApplyDrop);

            InitializeComponent();
        }
Esempio n. 7
0
        //private void Drag(DragCommandParameter parameter)
        //{
        //  if (Picture != null)
        //  {
        //    IDataObject dataObject = DragDropBehavior.CreateDataObject(Picture);
        //    DragDropEffects effect = DragDrop.DoDragDrop(parameter.DragSource, dataObject, DragDropEffects.Move);
        //    if ((effect & DragDropEffects.Move) != 0)
        //      Picture = null;
        //  }
        //}


        private bool CanDrop(DropCommandParameter parameter)
        {
            // Extract data.
            var draggedPicture = DragDropBehavior.GetData(parameter.DragEventArgs.Data) as PictureViewModel;

            // To enable Drop the preview area needs to be empty and the dragged data needs to be a
            // picture.
            if (Picture == null && draggedPicture != null)
            {
                parameter.Data = draggedPicture;
                parameter.DragEventArgs.Effects = DragDropEffects.Move;
                return(true);
            }

            return(false);
        }
Esempio n. 8
0
        public ClusterEditorModel()
        {
            AddButtonCaption         = "Add ...";
            AddNodesToClusterCommand = new DelegateCommand(OnAddNodesToCluster, () => SelectedCluster != null);
            MouseDownCommand         = new DelegateCommand <MouseButtonEventArgs>(OnMouseDown);

            Root = new ClusterTreeNode(null);
            Root.IsDragAllowed = false;
            Root.IsDropAllowed = false;

            AddClusterCommand    = new DelegateCommand <ClusterTreeNode>(OnAddCluster, n => n == Root);
            DeleteClusterCommand = new DelegateCommand <ClusterTreeNode>(OnDeleteCluster, n => n.Parent == Root);

            myDragDropBehavior = new DragDropBehavior(Root);
            DropCommand        = new DelegateCommand <NodeDropRequest>(myDragDropBehavior.ApplyDrop);
        }
Esempio n. 9
0
        public TreeEditorViewModel()
        {
            Root = new Node();
            Root.IsDragAllowed = false;
            Root.IsDropAllowed = false;

            BuildTree();

            // as an example we only want to allow to add or delete processes
            CreateChildCommand = new DelegateCommand <Node>(OnCreateChild, n => n == Root);
            DeleteCommand      = new DelegateCommand <Node>(n => ((Node)n.Parent).Children.Remove(n), n => n.Parent == Root);

            var dragDropBehavior = new DragDropBehavior(Root);

            DropCommand = new DelegateCommand <NodeDropRequest>(dragDropBehavior.ApplyDrop);

            RefreshCommand = new DelegateCommand(BuildTree);
        }