Getting Started with NOV in WPF using only code

Getting Started with NOV in WPF using only code

1. Create a new WPF project in Visual Studio
  • From File Menu - Choose New Project
  • Select the Visual C# - WPF Application Template
  • Click OK

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 portable assembly;
Nevron.Nov.Host.WinBase.dll - base assembly for Windows presentation hosts (WinForm and WPF);
Nevron.Nov.Host.Wpf.dll - presentation host for WPF;

These assemblies are located in NOV installation folder: C:\Program Files (x86)\Nevron Software\Nevron Open Vision VERSION\Bin\Win

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:

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

using Nevron.Nov;
using Nevron.Nov.Windows;
using System;
namespace WpfApplication1
    static class Program
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        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"));
            NModule[] modules = new NModule[] {
                  // TODO: Create modules here
            // install Nevron Open Vision for WPF
            // run the application main window
            app.Run(new MainWindow());

3.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:

using Nevron.Nov.UI;
using Nevron.Nov.Windows;
using System.Windows;
namespace WpfApplication1
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
        public MainWindow()
            // 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.

Using Visual Basic .NET (VB.NET)
When you create a Visual Basic WPF Application, reference the NOV Assemblies and use the following code in your MainWindow.xaml.vb:

Imports Nevron.Nov
Imports Nevron.Nov.UI
Imports Nevron.Nov.Windows
Partial Public Class MainWindow
    Inherits Window
    Public Sub New()
        ' TODO: Apply license for redistribution here. You can skip this code when evaluating NOV.
        NLicenseManager.Instance.SetLicense(New NLicense("LICENSE KEY"))
        ' Install Nevron Open Vision modules
        Dim modules() As NModule = {}
        ' Add a NOV widget inside the form
        Dim sayHelloWorld As New NLabel("Hello World from Nevron Open Vision")
        Content = New NNovWidgetHost(Of NLabel)(sayHelloWorld)
    End Sub
End Class

This is as much as is required to host some NOV content in WPF. From now on you can forget everything you know about WPF, since you will not need it when developing with NOV.

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 NOV Help Documentation -> UI Overview topic for an overview of the User Interface that comes along with NOV.

Download Free Trial  Help Documentation
Send Feedback

Article ID: 240, Created On: 7/22/2016, Modified: 9/27/2016