Hi,
What is the best way to use an Infragistics WPF control (Network Node) in a C# .NET desktop application.
1) I am not seeing the Infragistics Network Node control under a C# .NET visual studio project.. I only see this control under WPF VS project.
2) Is there a Network Node control for visual studio C# .NET projects?
1) If not, can the Infragistics WPF Network Node control be used in a C# .NET visual studio project?
2) If so, what must be done? i.e. wrap (WPF Network Node control) in a WPF class lib?
Thanks !
Hoping someone can point me in the correct direction.
Brian
Hi Brian,
When you say that you are not seeing the XamNetworkNode app from within a C# .Net desktop app, I take that to mean that you aren’t seeing the control from within a Windows Forms project?
If that’s the case, then this is expected platform controls are generally* not cross compatible from one platform to the other; and you will not have access to Windows Forms controls from within a WPF project and vise-versa.
There is no equivalent to the XamNetworkNode control in Windows Forms, but it is possible via WPF/Windows Forms Interop to ‘host’ a WPF control in your Windows Forms application via a user control within a WinForms ElementHost component.
The general process for achieving this includes:
1. Create a ‘WPF User Control Library’
2. Setup the XamNetworkNode control in XAML or the code behind like you would normally
3. Implement any of your code behind, example for interactions, etc
4. From within your Windows Forms solution, add the user control library using the ‘Add New Project’ dialog
5. Add the library dll to your WinForms project references
6. Rebuild the solution
7. Add the ElementHost to your Windows Form
8. Add the newly available user control to the ElementHost
This process is initially pretty straight-forward and the hosted control will respond to interactions as you’d expect within its native WPF environment, but in order get/set any non-ambient properties or communicate data to/from the user-control from within Windows Forms, you would need to explicitly expose them from your new control as detailed in the following MSDN walkthrough.
Hosting a WPF Composite Control in Windows Forms:
https://msdn.microsoft.com/en-us/library/ms742215(v=vs.110).aspx
To give you a better idea of what a hosted XamNetworkNode implementation might look like, I have attached a sample project, using the above mentioned steps and included some interactions such as node selection that might be included in a common use-case.
Note: I’ve also included a more direct approach in the attached sample for getting at the underlying XamNetworkNodeControl object, note that you will need to add the InfragisticsWPF4.Controls.Maps.XamNetworkNode.v16.2 and InfragisticsWPF4.DataVisualization.v16.2 assemblies to your Winforms project references to take advantage of this approach.
Please have a look at the attached sample and if you have any further questions that I can help you with, let me know.
Chris K.
Thanks Chris K.
Excellent Answer ! most helpful.