Show / Hide Table of Contents

Class TextBoxDecimalMaskingBehavior

Microsoft.Xaml.Behaviors.Behavior for masking a System.Windows.Controls.TextBox to allow only entering of decimal values.

Inheritance
System.Object
System.Windows.Threading.DispatcherObject
System.Windows.DependencyObject
System.Windows.Freezable
System.Windows.Media.Animation.Animatable
Microsoft.Xaml.Behaviors.Behavior
Microsoft.Xaml.Behaviors.Behavior<System.Windows.Controls.TextBox>
TextBoxMaskingBehaviorBase
TextBoxDecimalMaskingBehavior
Implements
System.Windows.Media.Animation.IAnimatable
Microsoft.Xaml.Behaviors.IAttachedObject
TextBoxMaskingBehaviorBase.IsTextBoxClearingAllowed
TextBoxMaskingBehaviorBase.IsTextBoxClearingAllowedProperty
TextBoxMaskingBehaviorBase.OnAttached()
TextBoxMaskingBehaviorBase.OnDetaching()
Microsoft.Xaml.Behaviors.Behavior<System.Windows.Controls.TextBox>.AssociatedObject
Microsoft.Xaml.Behaviors.Behavior.CreateInstanceCore()
Microsoft.Xaml.Behaviors.Behavior.Attach(System.Windows.DependencyObject)
Microsoft.Xaml.Behaviors.Behavior.Detach()
Microsoft.Xaml.Behaviors.Behavior.AssociatedType
Microsoft.Xaml.Behaviors.Behavior.Microsoft.Xaml.Behaviors.IAttachedObject.AssociatedObject
System.Windows.Media.Animation.Animatable.ApplyAnimationClock(System.Windows.DependencyProperty, System.Windows.Media.Animation.AnimationClock)
System.Windows.Media.Animation.Animatable.ApplyAnimationClock(System.Windows.DependencyProperty, System.Windows.Media.Animation.AnimationClock, System.Windows.Media.Animation.HandoffBehavior)
System.Windows.Media.Animation.Animatable.BeginAnimation(System.Windows.DependencyProperty, System.Windows.Media.Animation.AnimationTimeline)
System.Windows.Media.Animation.Animatable.BeginAnimation(System.Windows.DependencyProperty, System.Windows.Media.Animation.AnimationTimeline, System.Windows.Media.Animation.HandoffBehavior)
System.Windows.Media.Animation.Animatable.Clone()
System.Windows.Media.Animation.Animatable.FreezeCore(System.Boolean)
System.Windows.Media.Animation.Animatable.GetAnimationBaseValue(System.Windows.DependencyProperty)
System.Windows.Media.Animation.Animatable.HasAnimatedProperties
System.Windows.Freezable.CloneCore(System.Windows.Freezable)
System.Windows.Freezable.CloneCurrentValue()
System.Windows.Freezable.CloneCurrentValueCore(System.Windows.Freezable)
System.Windows.Freezable.CreateInstance()
System.Windows.Freezable.Freeze()
System.Windows.Freezable.Freeze(System.Windows.Freezable, System.Boolean)
System.Windows.Freezable.GetAsFrozen()
System.Windows.Freezable.GetAsFrozenCore(System.Windows.Freezable)
System.Windows.Freezable.GetCurrentValueAsFrozen()
System.Windows.Freezable.GetCurrentValueAsFrozenCore(System.Windows.Freezable)
System.Windows.Freezable.OnChanged()
System.Windows.Freezable.OnFreezablePropertyChanged(System.Windows.DependencyObject, System.Windows.DependencyObject)
System.Windows.Freezable.OnFreezablePropertyChanged(System.Windows.DependencyObject, System.Windows.DependencyObject, System.Windows.DependencyProperty)
System.Windows.Freezable.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs)
System.Windows.Freezable.ReadPreamble()
System.Windows.Freezable.WritePostscript()
System.Windows.Freezable.WritePreamble()
System.Windows.Freezable.CanFreeze
System.Windows.Freezable.IsFrozen
System.Windows.Freezable.Changed
System.Windows.DependencyObject.ClearValue(System.Windows.DependencyProperty)
System.Windows.DependencyObject.ClearValue(System.Windows.DependencyPropertyKey)
System.Windows.DependencyObject.CoerceValue(System.Windows.DependencyProperty)
System.Windows.DependencyObject.Equals(System.Object)
System.Windows.DependencyObject.GetHashCode()
System.Windows.DependencyObject.GetLocalValueEnumerator()
System.Windows.DependencyObject.GetValue(System.Windows.DependencyProperty)
System.Windows.DependencyObject.InvalidateProperty(System.Windows.DependencyProperty)
System.Windows.DependencyObject.ReadLocalValue(System.Windows.DependencyProperty)
System.Windows.DependencyObject.SetCurrentValue(System.Windows.DependencyProperty, System.Object)
System.Windows.DependencyObject.SetValue(System.Windows.DependencyProperty, System.Object)
System.Windows.DependencyObject.SetValue(System.Windows.DependencyPropertyKey, System.Object)
System.Windows.DependencyObject.ShouldSerializeProperty(System.Windows.DependencyProperty)
System.Windows.DependencyObject.DependencyObjectType
System.Windows.DependencyObject.IsSealed
System.Windows.Threading.DispatcherObject.Dispatcher
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
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 Source

MaximumProperty

The allowed maximum value dependency property.

Declaration
public static readonly DependencyProperty MaximumProperty
Field Value
Type Description
System.Windows.DependencyProperty
View Source

MinimumProperty

The allowed minimum value dependency property.

Declaration
public static readonly DependencyProperty MinimumProperty
Field Value
Type Description
System.Windows.DependencyProperty
View Source

NumberOfAllowedDecimalPointsProperty

The number of allowed decimal points dependency property.

Declaration
public static readonly DependencyProperty NumberOfAllowedDecimalPointsProperty
Field Value
Type Description
System.Windows.DependencyProperty

Properties

View Source

Maximum

The allowed maximum value.

Declaration
public decimal? Maximum { get; set; }
Property Value
Type Description
System.Nullable<System.Decimal>
View Source

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.

View Source

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 Source

IsValid(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.

Overrides
TextBoxMaskingBehaviorBase.IsValid(String)

Implements

System.Windows.Media.Animation.IAnimatable
Microsoft.Xaml.Behaviors.IAttachedObject

Extension Methods

CollectionExtensions.AddRange<T, TCollection>(TCollection, IEnumerable<T>)
SerializableObjectCloneExtension.Clone<T>(T)
DependencyObjectExtensions.GetContainer(DependencyObject)
DependencyObjectExtensions.SetContainer(DependencyObject, CompositionContainer)
DependencyObjectExtensions.FindAncestor<T>(DependencyObject)
DependencyObjectExtensions.FindFirstChildByType<T>(DependencyObject)
DependencyObjectExtensions.FindLogicalAncestor<T>(DependencyObject)
DependencyObjectExtensions.GetChildsByType<T>(DependencyObject, List<T>)
DependencyObjectExtensions.GetChildrenByType<T>(DependencyObject)
DependencyObjectExtensions.XamlClone<T>(T)
  • View Source
Back to top Generated by DocFX