Class TextBoxDecimalMaskingBehavior
Microsoft.Xaml.Behaviors.Behavior for masking a System.Windows.Controls.TextBox to allow only entering of decimal values.
Inheritance
Implements
Namespace: Sartorius.SAF.Presentation.Behaviors
Assembly: Sartorius.SAF.Presentation.dll
Syntax
public class TextBoxDecimalMaskingBehavior : TextBoxMaskingBehaviorBase, IAnimatable, IAttachedObject
Remarks
The behavior does not work correctly on a System.Windows.Controls.TextBox which has it's System.Windows.Controls.TextBox.TextProperty bound to a System.Single value. Always bind to System.Decimal values.
Examples
The following example shows how to use the TextBoxDecimalMaskingBehavior to restrict entry of digits after the decimal to 2 and restrict the range from 0 to 100.
<StackPanel Orientation="Horizontal">
<TextBlock Style="{SAF:Style TextBlockContentBoxLabel}"
Text="Enter the percentage" />
<TextBox Style="{SAF:Style TextBoxSingleLine}"
Text="{Binding Percentage}"
Width="150">
<b:Interaction.Behaviors>
<SAF:TextBoxDecimalMaskingBehavior NumberOfAllowedDecimalPoints="2" Minimum="0" Maximum="100" />
</b:Interaction.Behaviors>
</TextBox>
</StackPanel>
Fields
View SourceMaximumProperty
The allowed maximum value dependency property.
Declaration
public static readonly DependencyProperty MaximumProperty
Field Value
Type | Description |
---|---|
System.Windows.DependencyProperty |
MinimumProperty
The allowed minimum value dependency property.
Declaration
public static readonly DependencyProperty MinimumProperty
Field Value
Type | Description |
---|---|
System.Windows.DependencyProperty |
NumberOfAllowedDecimalPointsProperty
The number of allowed decimal points dependency property.
Declaration
public static readonly DependencyProperty NumberOfAllowedDecimalPointsProperty
Field Value
Type | Description |
---|---|
System.Windows.DependencyProperty |
Properties
View SourceMaximum
The allowed maximum value.
Declaration
public decimal? Maximum { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.Decimal> |
Minimum
The allowed minimum value.
Declaration
public decimal? Minimum { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.Decimal> |
Remarks
Only values smaller than '10' are supported.
NumberOfAllowedDecimalPoints
Gets or sets the number of allowed decimal points.
Declaration
public int? NumberOfAllowedDecimalPoints { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.Int32> |
Methods
View SourceIsValid(String)
Checks wether the valueToValidate
matches the pattern to be valid.
Declaration
public override bool IsValid(string valueToValidate)
Parameters
Type | Name | Description |
---|---|---|
System.String | valueToValidate | The value for validation. |
Returns
Type | Description |
---|---|
System.Boolean | True if the value is valid, otherwise false. |