.Net 2.0 custom controls and WPF - wpf

out of curiosity i just want to know those custom control which was developed in .Net 2.0 version that can be reused in WPF application. if yes then what would be the process. usually we add custom control to the toolbox and just drag & drop those onto form and easily manipulate and work with them. so can we follow the same step to include those custom control developed with .net v2.0 onto WPF form or not. please discuss. thanks

You can reuse Windows Forms Controls in a WPF application (and the reverse is also true, you can host WPF controls in a Windows Forms application) .
Here is an official documentation link on this subject: Walkthrough: Hosting a Windows Forms Composite Control in WPF

Related

WPF native controls in Xamarin

I was playing around with Xamarin and WPF after following the BoxViewClock tutorial from the Xamarin website but apart from that one article, which has been duplicated on a number of sites I cannot find any other advanced examples.
Is it currently possible to add/use a WPF custom control to an xamarin forms page? or for that matter a view/user control?
You typically start creating a custom control by deriving from one of Xamarin.Forms controls and you do it in shared .NET Standard library with Xamarin.Forms UI project. As soon as there's behavior which is not feasible within Xamarin.Forms you create a native renderer in a project targeting specific platforms, in our case in WPF project. Thus there're 2 steps for creating custom controls in Xamarin.Forms:
Derive from existing Xamarin.Forms controls in Shared project
Add extensions to it via platform renderer (or behaviour which is a custom case of renderer) in platform project.
You can find example of creating "ExtendedLabel" control which adds to the standard Xamarin.Forms' Label with capability to change cursor to Hand when mouse hovers over the label in WPF application:
Xamarin.Forms control: https://github.com/maxim-saplin/CrossPlatformDiskTest/blob/master/Saplin.CPDT.UICore/Controls/ExtendedLabel.cs
WPF platfrom renderer: https://github.com/maxim-saplin/CrossPlatformDiskTest/blob/master/Saplin.CPDT.WPF/ExtendedLabelRenderer.cs - you can ignore the code after "if (label.FormattedText != null &&..." which is a workaround for a bug in Xamarin.WPF and not related to the questions
P.S.: in the repo there's also a renderer for macOS which implements the same behaviour

WPF - Windows Forms Interoperation

I am abit confused about interoperations between forms. I have an c#.Net application developed using DevExforms. On the other hand I have a XNA application which I want to use it as 3d GUI. But it is diffucult to interact between them. Of course it is not useful, it is ugly too.
So I see a way to develop 3d model viewer app using WPF but WPF controls and windows forms controls needs .Net Framework 4.5 to interact betwwen. But I must use VS2010.
So I am confused. What must I do. How can I easily develop a 3d app with Windows Forms or how can i interact any platform with my app. Actualy if you were me what will you do?
WPF controls and WinForms controls don't need .Net framework 4.5 to work together. the interoperability exists before (4.5). take a look in MSDN

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

Use WinForms custom textBox in WPF?

I have a WPF application that is in need of syntax highlighting. THIS is exactly what I'm looking for... however its for WinForms. Can I, and if so, how do I add it to my WPF program?
http://wpfsyntax.codeplex.com/
http://devhawk.net/2009/07/09/syntax-highlighting-textboxes-in-wpf-a-sad-story/
There's a walkthrough on MSDN
This walkthrough steps you through an application that hosts a Windows Forms composite control to perform data entry in a WPF application. The composite control is packaged in a DLL. This general procedure can be extended to more complex applications and controls.
In this scenario the WinForms controls are in a separate dll which needs to be signed.
The WPF application needs to use a WinFormsHost control as the container for the control.

Mixing WPF with a WinForm application?

My fairly large WinForm application needs a GUI overhaul, but I can't afford to do it all at once. I need to know if I can slowly add WPF into it, and if so, how?
Can I add WPF dialogs?
Can I add WPF 'panels' within a WinForm so that I can embed WPF elements?
EDIT
Can I do the opposite and put WinForm dialogs in my WPF application?
Yes, you can host WPF controls in your WinForms applications:
Walkthrough: Hosting a 3-D WPF Composite Control in Windows Forms
Walkthrough: Hosting a Composite WPF Control in Windows Forms
Yep, I've successfully mixed winforms and WPF. I even managed to add WPF windows to win32 apps, changed this app to a dll and used a WPF app to show win32 windows which show WPF windows.
To host WPF windows in WinForm or win32 apps you will need this line befor you .Show() your WpfWindow:
System.Windows.Forms.Integration.ElementHost.EnableModelessKeyboardInterop(myWpfWindow);
See http://msdn.microsoft.com/en-us/library/aa348549.aspx
You can use the ElementHost control found in the System.Windows.Forms.Integration namespace. You will need a reference to the WindowsFormsIntegration assembly (in WindowsFormsIntegration.dll)
This control is an empty container into which you can put WPF controls e.g.
myElementHost.Child = someWpfControl;
You can find it in your toolbox and drag and drop it onto a winform like any other control;

Resources