Embedding Our Gantt Software VARCHART XGantt in WPF
Embedding Our Gantt Software VARCHART XGantt .NET in WPF Applications
The rich functionality of our Gantt software VARCHART XGantt is also available in WPF applications. For integrating Windows Forms controls into WPF-Windows, Microsoft offers the WindowsFormsHost control that lets you use the .NET edition of VARCHART XGantt within a WPF-Windows as well. Below, please find the description of two alternative approaches:
Precondition: Adding required references
In both cases, to use the WindowsFormsHost control, the references to WindowsFormsIntegration, System.Windows.Forms and of course NETRONIC.XGantt have to be created.
Alternative 1: Integration by way of XAML code of the WPF Windows (Window1.xaml)
This approach integrates our Gantt software VARCHART XGantt within the XAML code:
<Window x:Class="WpfApplication1.Window1"
<Grid x:Name="grid1">
<WindowsFormsHost Margin="41,27,36,30" Name="windowsFormsHost1">
This approach does not integrate our Gantt software VARCHART XGantt by way of using XAML code but by using code-behind in C#. For this reason, the XAML code does not contain any specific characteristics, it is just a standard description of a WPF Windows.
<Window x:Class="WpfApplication1.Window1"
Now the WindowsFormsHost object is created in code-behind and a VcGantt object is added to this object as child.
using System.Windows.Forms.Integration;
using NETRONIC.XGantt;namespace WpfApplication1
{
Using the property pages for configuration
As, unfortunately, neither alternative offers the use of XGantt.NET's property pages, we recommend you to create a Windows form within the project so that this comfortable way of configuration is still available. You can then place another XGantt instance onto this form and carry out the desired settings on the property pages. This configuration can be exported as *.ini file and afterwards be reimported into the VcGantt object of the WPF Windows.
public Window1()
The NETRONIC components VARCHART XNet.NET and VARCHART XTree.NET can of course also be embedded in WPF applications in a similar way.
Helpful Links
- MSDN Library: "Walkthrough: Hosting a Windows Forms Control in Windows Presentation Foundation by Using XAML":
http://msdn.microsoft.com/en-us/library/ms742875.aspx - MSDN Library: "Walkthrough: Hosting a Windows Forms Control in Windows Presentation Foundation":
http://msdn.microsoft.com/en-us/library/ms751761.aspx
