Tooltips Example for WPF

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

Tooltips Example for WPF Description

The example demonstrates how to assign tooltips to different gauge elements.


Gauge Tooltips Example

C# Tooltips Example Code for Nevron Gauge for WPF
Language: C#

using Nevron.Nov;
using Nevron.Nov.Chart;
using Nevron.Nov.Dom;
using Nevron.Nov.Graphics;
using Nevron.Nov.Layout;
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 - NGaugeTooltipsExample";

			// 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();
			
			NStackPanel controlStack = new NStackPanel();
			stack.Add(controlStack);

			NRadialGauge radialGauge = new NRadialGauge();
			radialGauge.PreferredSize = defaultRadialGaugeSize;
			radialGauge.CapEffect = new NGlassCapEffect();
			radialGauge.Dial = new NDial(ENDialShape.Circle, new NEdgeDialRim());
			radialGauge.Dial.BackgroundFill = NAdvancedGradientFill.Create(ENAdvancedGradientColorScheme.Ocean2, 0);

			// configure scale
			NGaugeAxis axis = new NGaugeAxis();
			radialGauge.Axes.Add(axis);
			NLinearScale scale = axis.Scale as NLinearScale;
			scale.SetPredefinedScale(ENPredefinedScaleStyle.PresentationNoStroke);
			scale.Labels.OverlapResolveLayouts = new NDomArray();
			scale.MinorTickCount = 3;
			scale.Ruler.Fill = new NColorFill(NColor.FromColor(NColor.White, 0.4f));
			scale.OuterMajorTicks.Fill = new NColorFill(NColor.Orange);
			scale.Labels.Style.TextStyle.Font = new NFont("Arimo", 12.0, ENFontStyle.Bold | ENFontStyle.Italic);
			scale.Labels.Style.TextStyle.Fill = new NColorFill(NColor.White);

			m_Axis = (NGaugeAxis)radialGauge.Axes[0];

			controlStack.Add(radialGauge);

			m_Indicator1 = new NRangeIndicator();
			m_Indicator1.Value = 50;
			m_Indicator1.Fill = new NColorFill(NColor.LightBlue);
			m_Indicator1.Stroke.Color = NColor.DarkBlue;
			m_Indicator1.EndWidth = 20;
			m_Indicator1.AllowDragging = true;
			radialGauge.Indicators.Add(m_Indicator1);

			m_Indicator2 = new NNeedleValueIndicator();
			m_Indicator2.Value = 79;
			m_Indicator2.Fill = new NStockGradientFill(ENGradientStyle.Horizontal, ENGradientVariant.Variant1, NColor.White, NColor.Red);
			m_Indicator2.Stroke.Color = NColor.Red;
			m_Indicator2.AllowDragging = true;
			radialGauge.Indicators.Add(m_Indicator2);

			m_Indicator3 = new NMarkerValueIndicator();
			m_Indicator3.Value = 90;
			m_Indicator3.AllowDragging = true;
			radialGauge.Indicators.Add(m_Indicator3);

			radialGauge.SweepAngle = new NAngle(270.0, NUnit.Degree);

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

			NStackPanel propertyStack = new NStackPanel();
			stack.Add(new NUniSizeBoxGroup(propertyStack));

			m_RangeTooltipTextBox = new NTextBox();
			m_RangeTooltipTextBox.Text = "Range Tooltip";
			propertyStack.Add(new NPairBox("Range Tooltip:", m_RangeTooltipTextBox, true));

			m_NeedleTooltipTextBox = new NTextBox();
			m_NeedleTooltipTextBox.Text = "Needle Tooltip";
			propertyStack.Add(new NPairBox("Needle Tooltip:", m_NeedleTooltipTextBox, true));

			m_MarkerTooltipTextBox = new NTextBox();
			m_MarkerTooltipTextBox.Text = "Marker Tooltip";
			propertyStack.Add(new NPairBox("Marker Tooltip:", m_MarkerTooltipTextBox, true));

			m_ScaleTooltipTextBox = new NTextBox();
			m_ScaleTooltipTextBox.Text = "Scale Tooltip";
			propertyStack.Add(new NPairBox("Scale Tooltip:", m_ScaleTooltipTextBox, true));

			m_RangeTooltipTextBox.TextChanged += UpdateTooltips;
			m_NeedleTooltipTextBox.TextChanged += UpdateTooltips;
			m_MarkerTooltipTextBox.TextChanged += UpdateTooltips;
			m_ScaleTooltipTextBox.TextChanged += UpdateTooltips;

            UpdateTooltips(null);

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

The example demonstrates how to assign tooltips to different gauge elements.

"; } /// /// Gets the relevant documentation links for the example /// /// public (string Name, string Url)[] GetDocumentationUrls() { return new[] { ("ToolTips", "https://www.nevron.com/docs/openvision/ui-toolTips.html"), ("Gauges Overview", "https://www.nevron.com/docs/openvision/gauges-overview.html"), }; } #endregion #region Implementation private void UpdateTooltips(NValueChangeEventArgs arg) { if (m_Axis == null) return; m_Indicator1.Tooltip = new NTooltip(m_RangeTooltipTextBox.Text); m_Indicator2.Tooltip = new NTooltip(m_NeedleTooltipTextBox.Text); m_Indicator3.Tooltip = new NTooltip(m_MarkerTooltipTextBox.Text); } #endregion #region Event Handlers #endregion #region Fields NRangeIndicator m_Indicator1; NNeedleValueIndicator m_Indicator2; NMarkerValueIndicator m_Indicator3; NGaugeAxis m_Axis; NTextBox m_RangeTooltipTextBox; NTextBox m_NeedleTooltipTextBox; NTextBox m_MarkerTooltipTextBox; NTextBox m_ScaleTooltipTextBox; #endregion #region Static Methods #endregion #region Constants private static readonly NSize defaultRadialGaugeSize = new NSize(300, 300); #endregion #region Nested Types #endregion } }

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

VB.NET Tooltips Example Code for Nevron Gauge for WPF
Language: VB.NET

Imports Nevron.Nov
Imports Nevron.Nov.Chart
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 - NGaugeTooltipsExample"

		' 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()

            Dim controlStack As NStackPanel = New NStackPanel()
            stack.Add(controlStack)

            Dim radialGauge As NRadialGauge = New NRadialGauge()
            radialGauge.PreferredSize = defaultRadialGaugeSize
            radialGauge.CapEffect = New NGlassCapEffect()
            radialGauge.Dial = New NDial(ENDialShape.Circle, New NEdgeDialRim())
            radialGauge.Dial.BackgroundFill = NAdvancedGradientFill.Create(ENAdvancedGradientColorScheme.Ocean2, 0)

            ' configure scale
            Dim axis As NGaugeAxis = New NGaugeAxis()
            radialGauge.Axes.Add(axis)
            Dim scale As NLinearScale = TryCast(axis.Scale, NLinearScale)
            scale.SetPredefinedScale(ENPredefinedScaleStyle.PresentationNoStroke)
            scale.Labels.OverlapResolveLayouts = New NDomArray(Of ENLevelLabelsLayout)()
            scale.MinorTickCount = 3
            scale.Ruler.Fill = New NColorFill(NColor.FromColor(NColor.White, 0.4F))
            scale.OuterMajorTicks.Fill = New NColorFill(NColor.Orange)
            scale.Labels.Style.TextStyle.Font = New NFont("Arimo", 12.0, ENFontStyle.Bold Or ENFontStyle.Italic)
            scale.Labels.Style.TextStyle.Fill = New NColorFill(NColor.White)

            m_Axis = radialGauge.Axes(0)

            controlStack.Add(radialGauge)

            m_Indicator1 = New NRangeIndicator()
            m_Indicator1.Value = 50
            m_Indicator1.Fill = New NColorFill(NColor.LightBlue)
            m_Indicator1.Stroke.Color = NColor.DarkBlue
            m_Indicator1.EndWidth = 20
            m_Indicator1.AllowDragging = True
            radialGauge.Indicators.Add(m_Indicator1)

            m_Indicator2 = New NNeedleValueIndicator()
            m_Indicator2.Value = 79
            m_Indicator2.Fill = New NStockGradientFill(ENGradientStyle.Horizontal, ENGradientVariant.Variant1, NColor.White, NColor.Red)
            m_Indicator2.Stroke.Color = NColor.Red
            m_Indicator2.AllowDragging = True
            radialGauge.Indicators.Add(m_Indicator2)

            m_Indicator3 = New NMarkerValueIndicator()
            m_Indicator3.Value = 90
            m_Indicator3.AllowDragging = True
            radialGauge.Indicators.Add(m_Indicator3)

            radialGauge.SweepAngle = New NAngle(270.0, NUnit.Degree)

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

            Dim propertyStack As NStackPanel = New NStackPanel()
            stack.Add(New NUniSizeBoxGroup(propertyStack))

            m_RangeTooltipTextBox = New NTextBox()
            m_RangeTooltipTextBox.Text = "Range Tooltip"
            propertyStack.Add(New NPairBox("Range Tooltip:", m_RangeTooltipTextBox, True))

            m_NeedleTooltipTextBox = New NTextBox()
            m_NeedleTooltipTextBox.Text = "Needle Tooltip"
            propertyStack.Add(New NPairBox("Needle Tooltip:", m_NeedleTooltipTextBox, True))

            m_MarkerTooltipTextBox = New NTextBox()
            m_MarkerTooltipTextBox.Text = "Marker Tooltip"
            propertyStack.Add(New NPairBox("Marker Tooltip:", m_MarkerTooltipTextBox, True))

            m_ScaleTooltipTextBox = New NTextBox()
            m_ScaleTooltipTextBox.Text = "Scale Tooltip"
            propertyStack.Add(New NPairBox("Scale Tooltip:", m_ScaleTooltipTextBox, True))

            Me.m_RangeTooltipTextBox.TextChanged += AddressOf UpdateTooltips
            Me.m_NeedleTooltipTextBox.TextChanged += AddressOf UpdateTooltips
            Me.m_MarkerTooltipTextBox.TextChanged += AddressOf UpdateTooltips
            Me.m_ScaleTooltipTextBox.TextChanged += AddressOf UpdateTooltips

            UpdateTooltips(Nothing)

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

The example demonstrates how to assign tooltips to different gauge elements.

" End Function ''' ''' Gets the relevant documentation links for the example ''' ''' Public Function GetDocumentationUrls() As (String, String)() Return {("ToolTips", "https://www.nevron.com/docs/openvision/ui-toolTips.html"), ("Gauges Overview", "https://www.nevron.com/docs/openvision/gauges-overview.html")} End Function #End Region #Region "Implementation" Private Sub UpdateTooltips(arg As NValueChangeEventArgs) If m_Axis Is Nothing Then Return m_Indicator1.Tooltip = New NTooltip(m_RangeTooltipTextBox.Text) m_Indicator2.Tooltip = New NTooltip(m_NeedleTooltipTextBox.Text) m_Indicator3.Tooltip = New NTooltip(m_MarkerTooltipTextBox.Text) End Sub #End Region #Region "Event Handlers" #End Region #Region "Fields" Private m_Indicator1 As NRangeIndicator Private m_Indicator2 As NNeedleValueIndicator Private m_Indicator3 As NMarkerValueIndicator Private m_Axis As NGaugeAxis Private m_RangeTooltipTextBox As NTextBox Private m_NeedleTooltipTextBox As NTextBox Private m_MarkerTooltipTextBox As NTextBox Private m_ScaleTooltipTextBox As NTextBox #End Region #Region "Static Methods" #End Region #Region "Constants" Private Shared ReadOnly defaultRadialGaugeSize As NSize = New NSize(300, 300) #End Region #Region "Nested Types" #End Region End Class

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

Related Documentation Links