Any Equivalent of ReorderList Control in Winform? - winforms

ASP.NET has a reorderlist control
http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/ReorderList/ReorderList.aspx
Is there anything equivalent (control, source code, ...) in Winform ?

ObjectListView -- an open source wrapper around a WinForms ListView -- has the ability to rearrange objects in the list through dragging, much like the demo you gave.
Have a look at the "Drag and Drop" tab in the demo and read this recipe.

Related

vb.net - Can I load a wpf form into a canvas/grid control?

I trying to see if its possible to load a form into a canvas or grid control in wpf with vb.net.
I'm not very familiar with WPF at all, usually working with Winforms more than anything else, however I need to take advantage of the far superior transparancy options offered by WPF for this current project, so need to see if I can crack this.
In Winforms, I'd normally have a panel (call it contentpanel or mainpanel etc) and then whenever I needed to I could easily load another form into that panel dynamically and keep everything neat and tidy in one form when presented to the user, so something like...
dim newforminstance as form1
newforminstance.toplevel = true
newforminstance.topmost = false
contentpanel.controls.add(newforminstance)
newforminstance.show
That works a treat in Winforms; Is there a similar way to achieve this functionality in WPF?
Thanks in advance.

How to retrieve a default style with Expression Blend?

From what I know, Expression Blend is the only method to look at a default style for some WPF control. But I find it very unelegant to create a new project, find a directory to save it to, add the element to my empty window designer and find some hidden "edit template copy" command or so.
And it totally fails when I want to get a DataGridCell style because I can't add it to the window.
How is this really correctly and efficiently done?
If Expression Blend is not involved in the better solution, please go ahead and let me know. Something directly available from VS 2010 would be best.
It's not the only method, but it is generally the easiest route since Blend by far makes for a better designing experience.
For you issue, I forget the names of the Default resource dictionaries for WPF. Like with SL you'd just go look into the CoreStyles, SDKStyles, ToolkitStyles (.xaml) files for the full templates. I'm pretty sure the same exists in WPF wherein you could likely locate them with a quick solution search for TargetType="{blah}" or wherever they're referenced to be loaded.
Otherwise you can continue with the right-click "Edit Template" method, and for a child part of a template (like a DataGridCell style) you would instead choose "Edit Additional Templates" and find that part of the template there the same way.
However like I said you can go straight to the templates themselves, just have to find the default dictionaries first. Hope this helps.

Drag and drop a file into application window using WPF and data binding

I'd like to be able to drag and drop a file (e.g. from Desktop or Explorer) right into the main window of a WPF application.
I also want no code behind, i.e. I want to use data binding.
So far I tested the "gong-wpf-dragdrop" which doesn't seem to support drag targets outside the application.
I could drop a file to the main window and the drag and drop events fired - but the data was empty (dragged a non-empty text file).
EDIT: gong-wpf-dragdrop works (after a small fix) and the problem also occurred when using code behind.
So the complete solution was to use gong wpf (github) and the solution presented by Omribitan.
have you tried GetFileDropList method? you can retreive it from the e.Data in the Drop event.
Something like:
string filename = (string)((DataObject)e.Data).GetFileDropList()[0];

WPF search windows - like tabPages in tab control

I have idea to implement my wpf windows like TabPages in tab control. It is possible to do that dynamically in c# code.
In Example i have Menu in main window. Some Menu items calls search type windows. Is it possible to do such a thing in C# code (SomeMenuItem_Click): this code adds new tab in tabControl of main window.
If there are no search windows called -there is no tab's shown, if there are many search windows called - there are many tab's.
So how do I code this?
And whats the technique with the windows? I suppose that my search type windows must be implemented like some UserControls. I think its no a good idea to implement that like simple wpf windows. I have tried to do that by using Marlon grech "Blend like UIs using DOCKY", find at:
http://marlongrech.wordpress.com/2008/01/29/create-blend-like-uis-using-docky/
But I failed, dont find the way how to add controlls in code dynamically, not in xaml.
I would appreciate code examples to illustrate how to achieve this.
Is it possible to do such a thing in C# code (SomeMenuItem_Click): this code adds new tab in tabControl of main window.
Yes. The basic pattern is:
TabItem newItem = new TabItem();
tabControl.Items.Add(newItem);
You'll obviously need to set the relevant properties of your tab item (such as the Header and Style) but that should get you started.
You'll then need to create any controls you want to show and add them to the tab item itself (or more correctly - a container within the tab item).

drag and drop in winforms or wpf

i would like to create a simple winforms or wpf application where i can drag and drop virtual "cards". this below is not exactly what i want to do, but it the closest thing that i found on the web to represent the user interface.
http://www.greenpeppersoftware.com/confluence/plugins/advanced/gallery-slideshow.action?imageNumber=1&pageId=24870977&decorator=popup&galleryTitle=Task+board+and+transitions
so basically i want to have columns in the GUI where i can drag and drag from one to the other.
My questions are:
would this be easier in winforms or wpf
where do i start?
In both winForms and WPF dragging and dropping can be done in a similar way by working with the events on the target DragOver and Drop.
However with WPF you have other options. You will also be able to make the application look better by having a thumbnail as you drag (this is possible in winforms but harder to achieve).
Have a look at this WPF sample it uses a helper class and think it does exactly what you need.
I agree with John in that WinForms and WPF are quite close to one another w.r.t. drag'n'drop. But WPF offers more of a "common base" for ItemsControl, allowing to implement more independent of the final UI elements used (ListBox, ListView, TreeView... can be easily switched). And obviously WPF allows much more fancy effects.
I would strongly recommend this blog post:
http://www.beacosta.com/blog/?p=53
both for some drag'n'drop basics and for a clean WPF drag'n'drop approach.
It shows a nice implementation of a rather generic helper for drag'n'drop from/to WPF ItemsControls, I really like that "Insertion Adorner". And I do like that the drag'n'drop code is nicely separated from the user control itself by using attached properties, which makes it much easier to use and maintain.
It would probably be slightly easier in WPF because of the Thumb control which provides easy to use built-in support for dragging. (If I remember correctly, in WinForms you would need to handle the mouse events yourself, whereas the WPF Thumb does this for you and translates them into drag start, delta and end events.)
However if you are much more familiar with one framework than the other than that would probably dwarf the difference that the Thumb control would make.
You should also have a look around for toolkits/frameworks that could handle this for you -- I think they exist for both WinForms and WPF (not sure though).
A good way for darg and drop are explained as
Detect a drag as a combinatination of MouseMove and MouseLeftButtonDown
Find the data you want to drag and create a DataObject that contains the format, the data and the allowed effects.
Initiate the dragging by calling DoDragDrop()
Set the AllowDrop property to True on the elements you want to allow dropping.
Register a handler to the DragEnter event to detect a dragging over the drop location. Check the format and the data by calling GetDataPresent() on the event args. If the data can be dropped, set the Effect property on the event args to display the appropriate mouse cursor.
When the user releases the mouse button the DragDrop event is called. Get the data by calling the GetData() method on the Data object provided in the event args.
You can find the complete article here

Resources