Splitter Example for Blazor

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

Splitter Example for Blazor Description

This example demonstrates how to create and configure a splitter. The splitter is a widget that splits its content area into two resizable panes, which can be interactively resized with help of a thumb located in the middle. Using the Orientation property you can specify whether the splitter is horizontal or vertical. To control how the splitter splits its content area you can use the SplitMode property.


Splitter Example

C# Splitter Example Code for Nevron UserInterface for Blazor
Language: C#

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

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

		public Form1()
		{
			InitializeComponent();

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

			// 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()
		{
			// Create a splitter
			m_Splitter = new NSplitter();

			m_Splitter.Pane1.Content = new NLabel("Pane 1");
			m_Splitter.Pane1.Padding = new NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing);
			m_Splitter.Pane1.BackgroundFill = new NColorFill(NColor.LightGreen);
			m_Splitter.Pane1.Border = NBorder.CreateFilledBorder(NColor.Black);
			m_Splitter.Pane1.BorderThickness = new NMargins(1);

			m_Splitter.Pane2.Content = new NLabel("Pane 2");
			m_Splitter.Pane2.Padding = new NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing);
			m_Splitter.Pane2.BackgroundFill = new NColorFill(NColor.LightBlue);
			m_Splitter.Pane2.Border = NBorder.CreateFilledBorder(NColor.Black);
			m_Splitter.Pane2.BorderThickness = new NMargins(1);

			m_Splitter.ResizeStep = 20;

			// Host it
			return m_Splitter;
		}
		public NWidget CreateExampleControls()
		{
			NStackPanel stack = new NStackPanel();

			// Create some splitter property editors
			NList editors = NDesigner.GetDesigner(m_Splitter).CreateMemberEditors(
				m_Splitter,
				NSplitterBase.OrientationProperty,
				NSplitterBase.ResizeWhileDraggingProperty,
				NSplitterBase.ResizeStepProperty);

			NStackPanel propertyStack = new NStackPanel();			
			for (int i = 0; i < editors.Count; i++)
			{
				propertyStack.Add(editors[i]);
			}

			stack.Add(new NGroupBox("Splitter Properties", propertyStack));

			// Create splitter thumb property editors
			editors = NDesigner.GetDesigner(m_Splitter.Thumb).CreateMemberEditors(
				m_Splitter.Thumb,
				NSplitterThumb.SplitModeProperty,
				NSplitterThumb.SplitOffsetProperty,
				NSplitterThumb.SplitFactorProperty,
				NSplitterThumb.CollapseModeProperty
			);

			propertyStack = new NStackPanel();
			for (int i = 0; i < editors.Count; i++)
			{
				propertyStack.Add(editors[i]);
			}

			stack.Add(new NGroupBox("Splitter Thumb Properties", propertyStack));

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

This example demonstrates how to create and configure a splitter. The splitter is a widget that splits its content area into two resizable panes, which can be interactively resized with help of a thumb located in the middle. Using the Orientation property you can specify whether the splitter is horizontal or vertical. To control how the splitter splits its content area you can use the SplitMode property.

"; } /// /// Gets the relevant documentation links for the example /// /// public (string Name, string Url)[] GetDocumentationUrls() { return new[] { ("Splitter", "https://www.nevron.com/docs/openvision/ui-splitter.html"), ("Containers Overview", "https://www.nevron.com/docs/openvision/ui-containers-overview.html"), }; } #endregion #region Implementation #endregion #region Event Handlers #endregion #region Fields private NSplitter m_Splitter; #endregion #region Static Methods #endregion #region Constants #endregion #region Nested Types #endregion } }

Download a fully functional C# (.cs) Splitter Example for Blazor Solution

Related Documentation Links