Progress Window Example for WPF

Nevron NOV UserInterface for WPF ships with hundreds of examples with full source code, as part of the Nevron Open Vision Suite. All WPF UserInterface examples are also available as a stand-alone Visual Studio solution in C# and VB.NET, which you can download from the links below.

Progress Window Example for WPF Description

This example demonstrates how to create, show and close progress windows. They are typically used to indicate progress during long-running operations. Click the Show Window button to show a progress window and the Close Window button to close it. Use the controls on the right to configure the window.


Progress Window Example

C# Progress Window Example Code for Nevron UserInterface for WPF
Language: C#

using Nevron.Nov;
using Nevron.Nov.Dom;
using Nevron.Nov.Graphics;
using Nevron.Nov.Layout;
using Nevron.Nov.UI;
using Nevron.Nov.Windows.Forms;
using System;
using System.Windows.Forms;

namespace NovWinFormsProject
{
	public partial class Form1 : Form
	{
		#region Constructors

		public Form1()
		{
			InitializeComponent();

			// Set form title
			Text = "NOV WinForms - NProgressWindowExample";

			// Create the NOV example and its controls
			NWidget exampleContent = CreateExampleContent();
			NWidget exampleControls = CreateExampleControls();
			if (exampleControls != null)
			{
				exampleControls.PreferredWidth = 300;
			}

			// Place the example and its controls in a pair box
			NPairBox pairBox = new NPairBox(exampleContent, exampleControls);
			pairBox.FillMode = ENStackFillMode.First;
			pairBox.FitMode = ENStackFitMode.First;
			pairBox.Margins = new NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing);

			// Host the example in the form
			NNovWidgetHost host = new NNovWidgetHost(pairBox);
			host.Dock = DockStyle.Fill;
			Controls.Add(host);
		}

		#endregion

		#region Example

		public NWidget CreateExampleContent()
		{
			NStackPanel stack = new NStackPanel();
			stack.Padding = new NMargins(10);
			stack.HorizontalPlacement = ENHorizontalPlacement.Left;

			m_ShowButton = new NButton("Show Window");
			m_ShowButton.Click += OnShowButtonClick;
			stack.Add(m_ShowButton);

			m_CloseButton = new NButton("Close Window");
			m_CloseButton.Enabled = false;
			m_CloseButton.Click += OnCloseButtonClick;
			stack.Add(m_CloseButton);

			m_IncreaseProgressButton = new NButton("Increase Progress");
			m_IncreaseProgressButton.Visibility = ENVisibility.Hidden;
			m_IncreaseProgressButton.Click += OnIncreaseProgressButtonClick;
			stack.Add(m_IncreaseProgressButton);

			return stack;
		}
		public NWidget CreateExampleControls()
		{
			NStackPanel stack = new NStackPanel();

			m_ProgressHeaderTextBox = new NTextBox("Header Text");
			stack.Add(NPairBox.Create("Header:", m_ProgressHeaderTextBox));

			m_ProgressContentTextBox = new NTextBox("This is the content of the progress window.");
			stack.Add(NPairBox.Create("Content:", m_ProgressContentTextBox));

			m_ProgressFooterTextBox = new NTextBox("Footer Text");
			stack.Add(NPairBox.Create("Footer:", m_ProgressFooterTextBox));

			m_ShowCancelButtonCheckBox = new NCheckBox();
			m_ShowCancelButtonCheckBox.Checked = true;
			m_ShowCancelButtonCheckBox.HorizontalPlacement = ENHorizontalPlacement.Left;
			stack.Add(NPairBox.Create("Cancel button:", m_ShowCancelButtonCheckBox));

			return new NUniSizeBoxGroup(stack);
		}
		public string GetExampleDescription()
		{
			return @"

This example demonstrates how to create, show and close progress windows. They are typically used to indicate progress during long-running operations. Click the Show Window button to show a progress window and the Close Window button to close it. Use the controls on the right to configure the window.

"; } /// /// Gets the relevant documentation links for the example /// /// public (string Name, string Url)[] GetDocumentationUrls() { return new[] { ("Progress Window", "https://www.nevron.com/docs/openvision/ui-progress-window.html"), ("Top Level Windows", "https://www.nevron.com/docs/openvision/ui-top-level-windows.html"), }; } #endregion #region Implementation #endregion #region Event Handlers private void OnShowButtonClick(NEventArgs arg) { m_ProgressWindow = NProgressWindow.Create(DisplayWindow, m_ProgressHeaderTextBox.Text); m_ProgressWindow.Content = String.IsNullOrEmpty(m_ProgressContentTextBox.Text) ? null : new NLabel(m_ProgressContentTextBox.Text); m_ProgressWindow.Footer = String.IsNullOrEmpty(m_ProgressFooterTextBox.Text) ? null : new NLabel(m_ProgressFooterTextBox.Text); if (m_ShowCancelButtonCheckBox.Checked) { m_ProgressWindow.ButtonStrip = new NButtonStrip(); m_ProgressWindow.ButtonStrip.AddCancelButton(); } m_ProgressWindow.Open(); m_CloseButton.Enabled = true; m_IncreaseProgressButton.Enabled = true; m_IncreaseProgressButton.Visibility = ENVisibility.Visible; } private void OnCloseButtonClick(NEventArgs arg) { m_ProgressWindow.Close(); m_CloseButton.Enabled = false; } private void OnIncreaseProgressButtonClick(NEventArgs arg) { m_ProgressWindow.ProgressBar.Value += 10; if (m_ProgressWindow.ProgressBar.Value >= m_ProgressWindow.ProgressBar.Maximum) { m_IncreaseProgressButton.Enabled = false; } } #endregion #region Fields private NProgressWindow m_ProgressWindow; private NButton m_ShowButton; private NButton m_CloseButton; private NButton m_IncreaseProgressButton; // Controls private NTextBox m_ProgressHeaderTextBox; private NTextBox m_ProgressContentTextBox; private NTextBox m_ProgressFooterTextBox; private NCheckBox m_ShowCancelButtonCheckBox; #endregion #region Static Methods #endregion #region Constants #endregion #region Nested Types #endregion } }

Download a fully functional C# (.cs) Progress Window Example for WPF Solution

VB.NET Progress Window Example Code for Nevron UserInterface for WPF
Language: VB.NET

Imports Nevron.Nov
Imports Nevron.Nov.Dom
Imports Nevron.Nov.Graphics
Imports Nevron.Nov.Layout
Imports Nevron.Nov.UI
Imports Nevron.Nov.Windows.Wpf

Class MainWindow

#Region "Constructors"

	Public Sub New()
		' This call is required by the designer.
		InitializeComponent()

		' Add any initialization after the InitializeComponent() call.

		' Set form title
		Title = "NOV WPF - NProgressWindowExample"

		' Create the NOV example and its controls
		Dim exampleContent As NWidget = CreateExampleContent()
		Dim exampleControls As NWidget = CreateExampleControls()
		If Not exampleControls Is Nothing Then
			exampleControls.PreferredWidth = 300
		End If

		' Place the example and its controls in a pair box
		Dim pairBox As NPairBox = New NPairBox(exampleContent, exampleControls)
		pairBox.FillMode = ENStackFillMode.First
		pairBox.FitMode = ENStackFitMode.First
		pairBox.Margins = New NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing)

		' Host the example in the form
		Dim host As NNovWidgetHost(Of NWidget) = New NNovWidgetHost(Of NWidget)(pairBox)
		Content = host
	End Sub


#End Region

#Region "Example"

        Public Function CreateExampleContent() As NWidget
            Dim stack As NStackPanel = New NStackPanel()
            stack.Padding = New NMargins(10)
            stack.HorizontalPlacement = ENHorizontalPlacement.Left

            m_ShowButton = New NButton("Show Window")
            Me.m_ShowButton.Click += AddressOf OnShowButtonClick
            stack.Add(m_ShowButton)

            m_CloseButton = New NButton("Close Window")
            m_CloseButton.Enabled = False
            Me.m_CloseButton.Click += AddressOf OnCloseButtonClick
            stack.Add(m_CloseButton)

            m_IncreaseProgressButton = New NButton("Increase Progress")
            m_IncreaseProgressButton.Visibility = ENVisibility.Hidden
            Me.m_IncreaseProgressButton.Click += AddressOf OnIncreaseProgressButtonClick
            stack.Add(m_IncreaseProgressButton)

            Return stack
        End Function
        Public Function CreateExampleControls() As NWidget
            Dim stack As NStackPanel = New NStackPanel()

            m_ProgressHeaderTextBox = New NTextBox("Header Text")
            stack.Add(NPairBox.Create("Header:", m_ProgressHeaderTextBox))

            m_ProgressContentTextBox = New NTextBox("This is the content of the progress window.")
            stack.Add(NPairBox.Create("Content:", m_ProgressContentTextBox))

            m_ProgressFooterTextBox = New NTextBox("Footer Text")
            stack.Add(NPairBox.Create("Footer:", m_ProgressFooterTextBox))

            m_ShowCancelButtonCheckBox = New NCheckBox()
            m_ShowCancelButtonCheckBox.Checked = True
            m_ShowCancelButtonCheckBox.HorizontalPlacement = ENHorizontalPlacement.Left
            stack.Add(NPairBox.Create("Cancel button:", m_ShowCancelButtonCheckBox))

            Return New NUniSizeBoxGroup(stack)
        End Function
        Public Function GetExampleDescription() As String
            Return "

This example demonstrates how to create, show and close progress windows. They are typically used to indicate progress during long-running operations. Click the Show Window button to show a progress window and the Close Window button to close it. Use the controls on the right to configure the window.

" End Function ''' ''' Gets the relevant documentation links for the example ''' ''' Public Function GetDocumentationUrls() As (String, String)() Return {("Progress Window", "https://www.nevron.com/docs/openvision/ui-progress-window.html"), ("Top Level Windows", "https://www.nevron.com/docs/openvision/ui-top-level-windows.html")} End Function #End Region #Region "Implementation" #End Region #Region "Event Handlers" Private Sub OnShowButtonClick(arg As NEventArgs) m_ProgressWindow = NProgressWindow.Create(DisplayWindow, m_ProgressHeaderTextBox.Text) m_ProgressWindow.Content = If(String.IsNullOrEmpty(m_ProgressContentTextBox.Text), Nothing, New NLabel(m_ProgressContentTextBox.Text)) m_ProgressWindow.Footer = If(String.IsNullOrEmpty(m_ProgressFooterTextBox.Text), Nothing, New NLabel(m_ProgressFooterTextBox.Text)) If m_ShowCancelButtonCheckBox.Checked Then m_ProgressWindow.ButtonStrip = New NButtonStrip() m_ProgressWindow.ButtonStrip.AddCancelButton() End If m_ProgressWindow.Open() m_CloseButton.Enabled = True m_IncreaseProgressButton.Enabled = True m_IncreaseProgressButton.Visibility = ENVisibility.Visible End Sub Private Sub OnCloseButtonClick(arg As NEventArgs) m_ProgressWindow.Close() m_CloseButton.Enabled = False End Sub Private Sub OnIncreaseProgressButtonClick(arg As NEventArgs) m_ProgressWindow.ProgressBar.Value += 10 If m_ProgressWindow.ProgressBar.Value >= m_ProgressWindow.ProgressBar.Maximum Then m_IncreaseProgressButton.Enabled = False End If End Sub #End Region #Region "Fields" Private m_ProgressWindow As NProgressWindow Private m_ShowButton As NButton Private m_CloseButton As NButton Private m_IncreaseProgressButton As NButton ' Controls Private m_ProgressHeaderTextBox As NTextBox Private m_ProgressContentTextBox As NTextBox Private m_ProgressFooterTextBox As NTextBox Private m_ShowCancelButtonCheckBox As NCheckBox #End Region #Region "Static Methods" #End Region #Region "Constants" #End Region #Region "Nested Types" #End Region End Class

Download a fully functional VB.NET (.vb) Progress Window Example for WPF Solution

Related Documentation Links