Step Interval in WPF Percent TextBox

18 Nov 20184 minutes to read

The WPF Percent TextBox control allows you to increase or decrease the percent value by pressing up-arrow and down-arrow keys in keyboard or mouse wheel over the control. The ScrollInterval property is used to specify the increment or decrement interval. The default value of ScrollInterval is 1.

For example, the ScrollInterval value is set to 4. So, that the WPF Percent TextBox control PercentValue increases or decreases by 4 while pressing Up arrow or Down arrow keys and Mouse wheel scrolling up or down.

Change Value on Up, Down arrow key

The WPF Percent TextBox control allows you to increase or decrease the PercentValue of WPF Percent TextBox based on the ScrollInterval by pressing the up arrow and down arrow keys on the keyboard.

<syncfusion:PercentTextBox x:Name="percentTextBox" Width="150"
                          Height="25" PercentValue ="10" ScrollInterval="2"/>
PercentTextBox percentTextBox = new PercentTextBox();
percentTextBox.Width = 150;
percentTextBox.Height = 25;
percentTextBox.PercentValue = 10;
percentTextBox.ScrollInterval = 2;

Changing Value by Up and Down Arrow Key in WPF PercentTextBox

Change Value on Mouse Wheel

The WPF Percent TextBox allows you to increase or decrease the PercentValue based on the ScrollInterval by scrolling the mouse wheel over the control when the IsScrollingOnCircle property is true. The default value of the IsScrollingOnCircle property is true. If ScrollInterval is set to 0 or a negative value, the value will not change.

<syncfusion:PercentTextBox x:Name="percentTextBox" Width="150" Height="25" PercentValue ="34" 
                          IsScrollingOnCircle="True" ScrollInterval="3"/>
PercentTextBox percentTextBox = new PercentTextBox();
percentTextBox.Width = 150;
percentTextBox.Height = 25;
percentTextBox.PercentValue = 34;
percentTextBox.IsScrollingOnCircle = true;
percentTextBox.ScrollInterval = 3;

Changing Value by Mouse Wheel in WPF PercentTextBox

Change Value on Click and Drag

The WPF Percent TextBox allows you to increase or decrease the percent value based on the ScrollInterval by clicking and dragging the mouse when the EnableExtendedScrolling property is true. The WPF Percent TextBox percent value increases when the cursor moves to the right or top of the screen and decreases when you click and drag the mouse to the left or bottom of the screen. Before that, the control must be unfocused (must not have keyboard focus).

<syncfusion:PercentTextBox x:Name="percentTextBox" Width="120" Height="25" PercentValue ="10" 
                          ScrollInterval="5" EnableExtendedScrolling="True"/>
PercentTextBox percentTextBox = new PercentTextBox();
percentTextBox.Width = 120;
percentTextBox.Height = 25;
percentTextBox.PercentValue = 10;
percentTextBox.ScrollInterval = 5;
percentTextBox.EnableExtendedScrolling = true;

Changing Value by Clicking and Drag in WPF PercentTextBox

Allow or restrict selection on focus

WPF Percent TextBox allows you to automatically select text when the control gets focus by setting the TextSelectionOnFocus property to true. If you want to restrict the selection when the control gets focus, set the TextSelectionOnFocus property value to false. The default value of the TextSelectionOnFocus property is true.

<syncfusion:PercentTextBox x:Name="percentTextBox" TextSelectionOnFocus="False"/>
PercentTextBox percentTextBox = new PercentTextBox();
percentTextBox.TextSelectionOnFocus = true;

TextSelectionOnFocus = False

Restrict Text Selection in WPF PercentTextBox

TextSelectionOnFocus = True

WPF PercentTextBox displays Text Selection