Nevron Open Vision Documentation
Integrating NOV in WPF

There are two ways in which NOV can integrate in a WPF application - by dragging and dropping NOV controls from the toolbox (Designer Integration) and by writing code (Code Integration).

The hosting of NOV in your application is by default performed by NOV project templates. If you are using project templates you can skip this documentation topic.
If you are using Visual Studio 2010 make sure that you target ".NET Framework 4.0" not ".NET Framework 4.0 Client Profile". 
Designer (Toolbox) Integration

You can simply drag and drop NOV controls from the Visual Studio Toolbox. The Visual Studio Designer will automatically add the necessary dll references to your project and you can start coding directly. The following code snippet shows how to say "Hello World from Nevron Open Vision" using this type:

1. Drag and Drop the NLabelControl from the "Nevron NOV Controls" toolbox category to the main windows of your application.

2. Open the MainWindow.xaml file and make sure that the label control has a name:

Installing NOV in WPF
Copy Code
<WpfControls:NLabelControl Name="nLabelControl1" HorizontalAlignment="Left" Height="100" Margin="192,131,0,0" VerticalAlignment="Top" Width="100"/>

3. Write the following code in MainWindow constructor:

Installing NOV in WPF
Copy Code

using System.Windows;

namespace WpfApp3
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            nLabelControl1.Widget.Text = "Hello World from NOV";
        }
    }
}

That's it - you have created your first WPF application using a NOV control. For more information check out the Integrating NOV from the Visual Studio Toolbox topic.

Coded Integration

1. Create a new WPF project in Visual Studio

This step is not mandatory, because you can integrate NOV in an already existing WPF project. It is performed just for the purpose of making a complete installation scenario.

2. Reference the NOV Assemblies

Ensure that your application references the following NOV dlls:

  • Nevron.Nov.Presentation.dll - Core NOV assembly.
  • Nevron.Nov.Host.WinBase.dll - base assembly for Windows presentation hosts (WinForm and WPF). 
  • Nevron.Nov.Host.Wpf.dll - presentation host for WPF. 
  • Nevron.Nov.Barcode.dll - NOV Barcode.
  • Nevron.Nov.Chart.dll - NOV Chart.
  • Nevron.Nov.Diagram.dll - NOV Diagram.
  • Nevron.Nov.Grid.dll - NOV Grid.
  • Nevron.Nov.Schedule.dll - NOV Schedule.
  • Nevron.Nov.Text.dll - NOV Text.

 

3. Initialize the NOV Application

The WPF project template does not create a custom application entry point, so you need to do that by yourself. Follow these steps:

1. Create a new Program.cs file in your project and copy-paste the following content:

Installing NOV for WPF
Copy Code
using System;
using Nevron.Nov;
using Nevron.Nov.Barcode;
using Nevron.Nov.Chart;
using Nevron.Nov.Diagram;
using Nevron.Nov.Grid;
using Nevron.Nov.Schedule;
using Nevron.Nov.Text;
using Nevron.Nov;
using Nevron.Nov.Windows;
namespace WpfApplication1
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            // create the application
            App app = new App();

            // Apply license for redistribution here. You can skip this code when evaluating NOV.
            NLicenseManager.Instance.SetLicense(new NLicense("LICENSE KEY"));
                
            // Install NOV
            NModule[] modules = new NModule[] {
                NBarcodeModule.Instance,
                NChartModule.Instance,
                NDiagramModule.Instance,
                NGridModule.Instance,
                NScheduleModule.Instance,
                NTextModule.Instance
            };
            // install Nevron Open Vision for WPF
            NNovApplicationInstaller.Install(modules);
            // run the application main window
            app.Run(new MainWindow());
        }
    }
}
See Hosting NOV in your Application for more information about modules.

2. Open the solution explorer and right click on the project to show the project properties. Select the Application tab and choose the WpfApplication1.Program in the Startup object combo box.

4. Say Hello World from NOV

Open the MainWindow.xaml.cs file and replace its content with the following code:

Say Hello World from NOV
Copy Code
using System.Windows;
using Nevron.Nov.UI;
using Nevron.Nov.Windows;
namespace WpfApplication1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            // Add a NOV widget inside the form
            NLabel sayHelloWorld = new NLabel("Hello World from Nevron Open Vision");
            Content = new NNovWidgetHost<NLabel>(sayHelloWorld);
        }
    }
}

Run the application - it should display a simple form with a "Hello World from Nevron Open Vision" label inside.

This is as much as is required to host some NOV content in WPF. The sample just makes a simple label, as content of the NNovWidgetHost WPF Control, but this control can actually contain any NOV widget. See the UI Overview topic for an overview of the User Interface that comes along with NOV.

 

See Also

UI

Send Feedback