Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • I want to create a listboxedit which has drag selection capabilities. The listboxedit has a wrappanel as itemspanel and has selectionmode set to extended. If the user drags he will see the selection. Once the drag is finished the items under the selection will be selected. I had this whole thing working with the regular ListBox, but now I had to implement the listboxedit here because we needed the drag and drop features.


                                    The code for obtaining all the listboxitems and setting the selected once was as follows:


                                    // Find and select all the list box items.
                                    for (int i = 0; i < this.DragTarget.Items.Count; i++)
                                    {
                                    // this.DragTarget.
                                    ListBoxItem item = (ListBoxItem)this.DragTarget.ItemContainerGenerator.ContainerFromIndex(i);

                                    Rect listBoxRect = new Rect(item.TranslatePoint(new Point(), this.DragTarget), item.RenderSize);
                                    if (dragRectangle.IntersectsWith(listBoxRect))
                                    this.DragTarget.SelectedItems.Add(item.Content);
                                    }


                                    However now I need to do the same for the lisboxedit and it's listboxedititems and I have no idea how to get these listboxedititems. Can you help me out with this? I'm asking this under the assumption that there is no better solution for this, if you already have something implemented for drag selection, I would gladly hear about this too.


                                    Thanks


                                    Yoni

                                You must  log in  or  register  to leave comments

                                1 Solution

                                0

                                Hi Yoni,

                                Thank you for your patience. We have an example that demonstrates how to implement the drag-and-drop functionality for ListBoxEdit - How to do drag and drop items from one ListBoxEdit to another. Please take a moment to review it. This example does not show how to implement multiple drag-and-drop, but you can realize it by using a similar method as shown in the Drag & drop "mutiple list items" from one ListBoxEdit control to another ListBoxEdit control & Drag & Drop list items within a ListBoxEdit control to rearrange the items thread.

                                Please review these tickets and feel free to reactivate this thread if the demonstrated approach does not meet your requirements.

                                Updated:

                                As for ListBoxEditItem objects, you can find them in the following manner:
                                1. Get a WrapPanel object by using the LayoutHelper class:

                                	
                                [C#]
                                WrapPanel panel = LayoutHelper.FindElement(DropTarget, n => n.GetType() == typeof(WrapPanel)) as WrapPanel; if(panel==null) return;
                                2. Look over ListBoxEditItem objects inside the WrapPanel object. Add the item's content to the ListBoxEdit.SelectedItems collection if the item intersects the dragRectangle object:
                                	
                                var en = panel.Children.GetEnumerator();
                                while(en.MoveNext()) {
                                    ListBoxEditItem item = en.Current as ListBoxEditItem;
                                    if(item == null)
                                        return;
                                    <!--check item-->
                                    Rect listBoxRect = new Rect(item.TranslatePoint(new Point(), this.DragTarget), item.RenderSize);
                                    if (dragRectangle.IntersectsWith(listBoxRect))
                                        DropTarget.SelectedItems.Add( item.DataContext);
                                }
                                
                                

                                If you have additional questions, feel free to reactivate this thread.

                                Thanks

                                Show all comments
                                • Yoni C 07.17.2012

                                  Hi Ivan,

                                  I don't really know how to reactivate this thread, so I'll just comment on your solution. The solution you provided is not exactly what I needed. But it gives my some info for my next step.

                                  I've created a dragselection control which acts similar to what microsoft does in the windows explorer when you hold the mouse down and select items.
                                  I had this thing working for a system.windows.control.listbox because I could loop through all the listboxitems and find there current postion on the screen. However now with the devexpress listboxedit, I do not now how to iterate through the listboxedititems and to find there screen positions. Can you give me a way to do this.

                                • Hello Yoni,

                                  Thank you for your response and providing the additional information. Please give us some time to examine your requirements in detail.

                                • Hi Yoni,

                                  I have updated my answer to demonstrate how this can be done. Please take a moment to review it.

                                • Yoni C 07.18.2012

                                  Your code worked well, however there is one thing that doesn't quite work. The selection is set because I can see there are items in the selecteditems however the selection doesn't get highlighted in the listboxEdit. Normally Clicking the listboxedit with selectionmode set to extended will highlight the items perfectly so, I must be missing something. Are you sure setting the selecteditems alone is enough?

                                • Yoni C 07.19.2012

                                  Ok never mind my last comment. I just upgraded to 12.1.5 and and the highlight now occurs as expected.
                                  Thank you very much for your support!

                                • Hi Yoni,

                                  I am glad to see that your problem was solved. You are welcome!

                                You must  log in  or  register  to leave comments
                                You must  log in  or  register  to leave an answer

                                Is your intention to post an answer to your own question?

                                • If so, then proceed.
                                • If you simply wanted to post additional information, ask for further clarification, or to just say "Thanks!", please click Leave a Comment.
                                • If you wish to edit your original question, please use the Edit button in the Toolbox at the top right corner of that entry.

                                To start a chat you should create a support ticket


                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Your Privacy - Legal Statements

                                Copyright © 1998-2013 Developer Express Inc.
                                ALL RIGHTS RESERVED
                                All trademarks or registered trademarks
                                are property of their respective owners