Homemade controls in WP7 Silverlight? - silverlight

In Windows Phone 7 Silverlight, is there a way to design a custom control from scratch - i. e. with custom drawing and custom touch processing? What do I subclass for that?

Yes you can. You usually subclass Control, ItemsControl, or ContentControl. Here is a blog post that explains the process in detail: Creating a WP7 Custom Control in 7 Steps

As mentioned, you can create a custom control from scratch by deriving from the Control class. To implement gesture handling you can use the GestureService from the Silverlight Toolkit for WIndows Phone 7 or you can directly handle the ManipulationStarted, ManipulationDelta, and ManipulationCompleted UIElement events.
Jeff Prosise has a great series of four posts that cover touch manipulation in great detail:
Part 1
Part 2
Part 3
Part 4
For the "custom drawing" part, what did you have in mind? If a control built up from primitives isn't what you had in mind, what about lines and shapes?

Related

User controls vs Custom Controls Silverliht

For developing a dashboard which will have many different widgets available, graphs, grids, etc, is a user control the best thing to use or a custom control?
I am a bit confused about the best situations to use each of them in
This relates to Silverlight 5
Paul
The key difference between user controls and custom controls is that custom controls can be re-templated, i.e. you can completely change their visuals by supplying a different template. If you do not need to do this in your application, I would recommend using user-controls as a simple alternative.
I have written a blog post about how to create them here:
A Simple Pattern for Creating Re-useable UserControls in WPF / Silverlight

Can we integrate a WinForms application with a WPF application?

I want to integrate two existing applications into one. One of those apps is built on Windows Forms and the other on WPF.
Is it possible to achieve this?
WPF supplies the WindowsFormsHost class that allows you to host WinForms controls inside a WPF window; conversely, WinForms supplies ElementHost that allows you to host WPF controls inside a form.
Unfortunately how well things work out is highly dependent on exactly what you are doing, last time I checked there were more than a few rough edges. For more information, definitely start from this MSDN page.
If you want to have "independent" WPF windows and WinForms forms inside the same application, you will have to make both frameworks "share" some code in your UI thread's message loop. For a primer on how to do that, see here.
There are various classes to help you with this.
For hosting Windows Forms controls in a WPF Window, you can use the WindowsFormsHost class. For hosting WPF Controls in a Windows Forms Window, you can use the ElementHost class.
You can look here for mor information on the subject (windows forms section):
http://msdn.microsoft.com/en-us/library/ms753178.aspx

WPF control and windows normal control

In a WinForms project there are a number of controls such as MenuStrip, OpenFileDialog, SaveFileDialog.
After a quick look, I can't seem to see the equivalents for these controls in the WPF toolbox.
Is there any way to gain access to these or do they exist in another form?
There are a number of different resources you can use for finding the type of control you need.
Have you looked in the WPF Toolkit?
Have you investigated any third party control vendors?
(Telerik, DevExpress, ComponentOne, Infragistics)
Here's an excellent link comparing the WinForms and WPF control equivalents.
You'd probably recieve a more detailed answer if you gave specifics as to which control you're looking for.
you can add a winforms host into the project but which controls are you after as the wpf does have a decent amount of controls and generally does more in the ui department (but pays in speed usually)

From WPF Control to Silverlight Control

we have biuld a complex custom control for WPF.
Now we are going to port our control to Silverlight.
Me and my collaborator, never work with silverlight! :)
Is there some best practice to follow to make a porting activity from WPF to Silverlight?
I find the next post as nice to be read: (2 parts)
Porting from WPF to Silverlight: The Missing Pieces, Part 1
Porting from WPF to Silverlight: The Missing Pieces, Part 2
There are some differences to be aware of, for example there are no Routed Commands in Silverlight. Maybe you want to have a look at those two links:
Contrasting Silverlight and WPF
Guidance on Differences Between WPF and Silverlight

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.

Resources