Creating a winforms app that allows drag and dropping of custom 'widgets' - winforms

I want to create a winforms application, this application will be similiar to the vs.net winforms designer (in certain aspects).
Basically it is going to be a blank page, where the user can drag and drop a bunch of 'widget's onto the screen. The widgets are basically custom images that I will create, that the user can resize, and it has some text on it by default which the user can double click on it to change the text.
Is this doable in winforms? If yes, what are the key aspects that I have to learn?

This is pretty easy to do in WinForms. Check out basic drag and drop. It's targeted toward 2.0. You'll use the DoDragDrop() method and capture data in drag and drop events. It requires some verbosity, but it gets the job done.
If you're keen on using WPF, take a look at MSDN's topic.

Related

Winforms - how to create something similar to a master page?

I'm trying to build an app in winforms with something similiar to masterpages in asp.net - a menu on top and when choosing an option from the menu the entire screen on the bottom will change while the menu remains (there are 10-15 screens in the future app, some are quite similar, some are not).
What is the best way of doing this? Should I use different forms for each screen or use a panel or something else?
If I use a panel or something how do I manage to use the designer with so many panels taking space on the screen?
Try with the MDIParent Form's. View the Example
http://www.codeproject.com/Articles/12514/Multi-Document-Interface-MDI-tab-page-browsing-wit
If it is just keeping the same menu and opening/closing parts of the UI you could simply add and remove instances of usercontrols to the main form.
If you need more features such as docking (like Visual Studio) look at this
Another option is to use Form inheritance
Which one to select depends on what you want to reuse and the features you need.
One option would be to make your application an MDI window and then load entire forms, maximized, into the parent window.
Then, you would be able to treat each form as its own self-contained item, since it really would be exactly that.
Is it not an option for you to use WPF? A WPF browser application fits the paradigm you are describing quite well.

Frames vs User controls in WPF

I'm writing a Windows application in WPF. I based my UI in a single menu and a tab control to display different documents or application forms. Since the menu as well as other things are fixed throughout the application, I need a way to display the contents of each TabItem. I have found two:
write a user control for each form, or
using a frame to display the content of each form.
The question
Is there any other single way for doing this. How do they compare in terms of clean code? I mean, in .net forms I only need load the form from the menu.
I know, I should go for any pattern like MVVM, but for this very first time I want to use the default approach.
I go with Frames and host Pages (not user controls). I like Pages over User Controls as the event model seems to have more hooks.

wpf using a windows form

I have a windows form that handles drag and drop of images just fine.Because I cannot find a way to do this in WPF can I add the form to a page and will the drag and drop still work? The images being dragged are from outside of app.
Thanks, Betsy
You can use a WindowsFormsHost in WPF to host Windows Forms controls. This will meet your requirements. Otherwise, take a look at Drag & Drop in WPF. This is fairly easy to implement.

Silverlight 4 Drag and Drop Alternatives

I want to add the ability to drag a user control from one part of a Silverlight 4 page onto another user control on the same page (not talking about the new Silverlight 4 ability to drag a file from the OS onto the page).
What approach is most straightforward? What approach offers the most flexibility?
Here are some alternatives I found so far
SO drag-and-drop-control-for-silverlight. Same question but answers apply to SL 2.
Alex van Beek's DragManager. Written for SL3.
Silverlight Drag Drop. Also written for SL3.
I can't compare all of the options you've listed but if I wanted to implement control to control drag drop feature I would the DragDrop and the DragDropTarget classes from the Silveright Toolkit. Its the only DragDrop framework I know of that has been refreshed for SL4 and if you already use elements from the Toolkit then that would be a natural solution.

Image drag and drop in wpf application

I want to drag and drop an image on wpf application form. Can anyone provide me the code and other links for that?
If you want to D&D within a single WPF application; then this code should get you going:
Drag and Drop within WPF
If you want to D&D between WPF applications, or between another non-WPF application you've got some options, but probably the easiest is to use a bitmap transfer (it takes a bit more code, so let me know and I'll publish it).

Resources