CADability dotNET

Using CADability in a WPF based application

  • CADability.CADControl is a Windows.Forms.Control which also can be used in a WPF based application. First you must add a reference to CADability in you application. Make sure all CADability DLLs (all DLLs in the CADability installation directory) are accessible to your application.

  • You must also add references to System.Windows.Forms and to WindowsFormsIntegration.

  • Now you have to modify the xaml file of your application: Add the following two namespaces to the properties of the "Window" element of the xaml file:

    CopyXML
    xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
    xmlns:cad="clr-namespace:CADability;assembly=CADability"

  • Add a WindowsFormsHost element to the Grid element in your xaml file.

    CopyXML
    <WindowsFormsHost HorizontalAlignment="Center" VerticalAlignment="Center" Width="811" Height="583" Margin="12">
      <cad:CADControl x:Name="CADControl1" ShowMenu="False" ShowControlCenter="True" ShowToolBars="True" Dock="Fill" FrameCreated="CADControl_FrameCreated"></cad:CADControl>
    </WindowsFormsHost>
    Provide a name for the control (like x:Name="CADControl1" ) to be able to access it in your code.

Example

CopyXML
<Window x:Class="WpfApplication3.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
        xmlns:cad="clr-namespace:CADability;assembly=CADability"
        Title="MainWindow" Height="646" Width="857">
  <Grid>
    <WindowsFormsHost HorizontalAlignment="Center" VerticalAlignment="Center" Width="811" Height="583" Margin="12">
      <cad:CADControl x:Name="CADControl1" ShowMenu="False" ShowControlCenter="True" ShowToolBars="True" Dock="Fill" FrameCreated="CADControl_FrameCreated"></cad:CADControl>
    </WindowsFormsHost>
  </Grid>
</Window>