I have a ListBox with a number of ListBoxItem objects. What is the best way to allow users to rearrange the items by dragging and dropping? Do I have to use StackPanels instead?
Thanks for any suggestions
You are going to use a different listbox control or build your own. Here is an example of building your own. Here is another one where he extends the silverlight toolkit listbox control.
For prosperity, the Silverlight Toolkit offers a set of DragDropTarget's which can be used to reorder items within a ListBox, TreeView, or a simple ItemsControl. You can also drag items between ItemsControls. Run the Silverligh 4 samples project and look at 'Drag and Drop' under the Toolkit section.
http://silverlight.codeplex.com/
http://www.silverlight.net/content/samples/sl4/toolkitcontrolsamples/run/default.html
The controls you want are:
ListBoxDragDropTarget
TreeViewDragDropTarget
DataPointSeriesDragDropTarget
Related
I'm am not good enough in WPF, so I'd like to ask for any advice how to implement panel layout something link displayed on image below:
So, the main purpose is to display a collection of items with possibility to select a single item, which should be moved to the first position (probably with animation) and then another item template should be applied to that container (it is bigger than other items in the collection). The list doesn't have to be infinitive, so just like a simple ListBox.
For me it looks like a FlipView but with a few items, which are neighboring siblings of the selected one and are also visible in the panel's viewport.
Please, advice me how to implement such a panel, or if you have seen something suitable, please, provide a link to the source.
You need to create your custom panel using User control.
Here is one example which is similar to your requirement.
I have a ItemControl and i set ItemPanel Property to Horizontal StackPanel and I Bound it to ObservableCollection of Icons.Now I Wanna user be able to remove icons with drag drop them to out of ItemControl and also can change items positions with each other by drag and Drop.
(Look likes MacOSX DocBar).Can i do this with above controls ,if yes,please tell me how.if not,i appreciate to tell me i should use which controls and how
Thanks In Advance.
You should be able to with your own inherited version of the controls. Microsoft writes their controls in a way to allow for easy inheriting and overriding of behavior.
It should be similar to what's done here:
http://www.codeproject.com/Articles/7841/Drag-and-Drop-Treeview-control
You want to watch events like DragStart, and DragLeave, and when it's not over your control and drop is performed do your operation.
More information:
http://msdn.microsoft.com/en-us/library/za0zx9y0.aspx
Good luck.
I need to add a custom item to ListView control (like on the picture), is it possible ? And if it is, what's the best way to do it ?
I don't know that this is possible with Winforms. The list items in a System.Windows.Forms.ListView are System.Windows.Forms.ListViewItem objects contained in a strongly typed collection.
You could try to create a subclass of ListViewItem, but since that class inherits directly from System.Object and is not an actual windows form control, you might be borrowing trouble, as you would need to replicate all the functionality of the inheritance chain of an actual control.
Now, if you are not too far in to the project, you might consider looking at switching to WPF. The ListView in WPF uses controls as items, so you could easily create a usercontrol that you would use as your list items.
You might be able to find a control library with a control that gives you the functionality you want, but for the most part, the good libraries are commercial and can be prohibitively expensive for small shops and individual .
I did a quick google search for any library that offers this capability, but I could not find one that displayed custom controls.
Not sure if this is what you're after, but ListViewItems have a Tag property that can store custom data about each item.
http://msdn.microsoft.com/en-us/library/system.windows.forms.listviewitem.tag.aspx
How about creating a user control. In that case you can set your user controls at the top and listview below. Or are you trying to add these controls as items in the listview itself?
I need a multi columned Treeview for an app I am writing, I was wondering if anyone knew of a free working (in Vs-2010) multi columned Treeview.
There are a number of sample controls to be found around the web:
TreeViewAdv for .Net
TreeView with Columns
ContainerListView and TreeListView
But the all-time favorite is probably the ObjectListView, which provides an expandable, multi-column ListView, along with many other incredibly handy features:
You can use this example here or download this control
Try this Microsof TreeListView WPF control
http://msdn.microsoft.com/en-us/library/vstudio/ms771523%28v=vs.90%29.aspx
You can do an illusion to the user in the user interface.
Drag a listview and drop this over the treeview which was already placed in the form.
Create columns in the listview as you need.
Set the 'HeaderStyle' property to 'Nonclickable' and 'Scrollabe' property to 'False' of the listview.
Set width and location of the listview as it fits to the treeview.
I would like to store and display a list of complex items. Each (graphic) item has to display an image, a list of color chips, a label and an index (a letter). User would also be able to zoom within each item, to show details of the image (on mousewheel),
Items would be presented in a vertical list, scrollable and resizable.
Language is C#, .net2.0, or 3.5 only if necessary.
I'm think about using custom UserControls for items (each one composed of a PictureBox, 2 Labels and a custom UserControl to display color chips).
For the list, I really don't know what to choose between a ListBox, a ListView, or a DataGridView, or another one I don't know yet.
I basically would go for a ListBox for its simplicity. Could you help me clarifying the advantages of using other lists?
If you expect to have a large number of these items, I strongly recommend that you do NOT make each one a UserControl. This is doubly important if you intend to localize and globalize the application at some point. The creation of these items will hinder performance.
Instead, take a lighter weight approach so that the items don't have the overhead of a full-blown control. Assuming that each item will be rectangular, you could easily create a UserControl for painting them, including a scrollbar to scroll.
in your case a custom (third party) list control seems to be the way to go. ListBox, a ListView or DataGridView are rather too limited given your requirements.
Regards,
tamberg
Thanks for your answers. It's very helpful to me.
I'm sorry I didn't mention that the list and its items have to manage drag-dropping with other controls. Then, I suppose that items have to be separate controls. Also, list would be dynamic and would not contain more than 30 items.
So, if I understand your advices, I should create a custom UserControl for the list and one for the item.