Show / Hide Table of Contents

Class TextBoxDecimalMaskingBehavior

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

Inheritance
object
DispatcherObject
DependencyObject
Freezable
Animatable
Behavior
Behavior<TextBox>
TextBoxMaskingBehaviorBase
TextBoxDecimalMaskingBehavior
Implements
IAnimatable
IAttachedObject
TextBoxMaskingBehaviorBase.IsTextBoxClearingAllowed
TextBoxMaskingBehaviorBase.IsTextBoxClearingAllowedProperty
TextBoxMaskingBehaviorBase.OnAttached()
TextBoxMaskingBehaviorBase.OnDetaching()
Behavior<TextBox>.AssociatedObject
Behavior.CreateInstanceCore()
Behavior.Attach(DependencyObject)
Behavior.Detach()
Behavior.AssociatedType
Animatable.ApplyAnimationClock(DependencyProperty, AnimationClock)
Animatable.ApplyAnimationClock(DependencyProperty, AnimationClock, HandoffBehavior)
Animatable.BeginAnimation(DependencyProperty, AnimationTimeline)
Animatable.BeginAnimation(DependencyProperty, AnimationTimeline, HandoffBehavior)
Animatable.Clone()
Animatable.FreezeCore(bool)
Animatable.GetAnimationBaseValue(DependencyProperty)
Animatable.HasAnimatedProperties
Freezable.CloneCore(Freezable)
Freezable.CloneCurrentValue()
Freezable.CloneCurrentValueCore(Freezable)
Freezable.CreateInstance()
Freezable.Freeze()
Freezable.Freeze(Freezable, bool)
Freezable.GetAsFrozen()
Freezable.GetAsFrozenCore(Freezable)
Freezable.GetCurrentValueAsFrozen()
Freezable.GetCurrentValueAsFrozenCore(Freezable)
Freezable.OnChanged()
Freezable.OnFreezablePropertyChanged(DependencyObject, DependencyObject)
Freezable.OnFreezablePropertyChanged(DependencyObject, DependencyObject, DependencyProperty)
Freezable.OnPropertyChanged(DependencyPropertyChangedEventArgs)
Freezable.ReadPreamble()
Freezable.WritePostscript()
Freezable.WritePreamble()
Freezable.CanFreeze
Freezable.IsFrozen
Freezable.Changed
DependencyObject.ClearValue(DependencyProperty)
DependencyObject.ClearValue(DependencyPropertyKey)
DependencyObject.CoerceValue(DependencyProperty)
DependencyObject.Equals(object)
DependencyObject.GetHashCode()
DependencyObject.GetLocalValueEnumerator()
DependencyObject.GetValue(DependencyProperty)
DependencyObject.InvalidateProperty(DependencyProperty)
DependencyObject.ReadLocalValue(DependencyProperty)
DependencyObject.SetCurrentValue(DependencyProperty, object)
DependencyObject.SetValue(DependencyProperty, object)
DependencyObject.SetValue(DependencyPropertyKey, object)
DependencyObject.ShouldSerializeProperty(DependencyProperty)
DependencyObject.DependencyObjectType
DependencyObject.IsSealed
DispatcherObject.Dispatcher
object.Equals(object, object)
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
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 TextBox which has it's TextProperty bound to a float value. Always bind to 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
DependencyProperty
View Source

MinimumProperty

The allowed minimum value dependency property.

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

NumberOfAllowedDecimalPointsProperty

The number of allowed decimal points dependency property.

Declaration
public static readonly DependencyProperty NumberOfAllowedDecimalPointsProperty
Field Value
Type Description
DependencyProperty

Properties

View Source

Maximum

The allowed maximum value.

Declaration
public decimal? Maximum { get; set; }
Property Value
Type Description
decimal?
View Source

Minimum

The allowed minimum value.

Declaration
public decimal? Minimum { get; set; }
Property Value
Type Description
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
int?

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
string valueToValidate

The value for validation.

Returns
Type Description
bool

True if the value is valid, otherwise false.

Overrides
TextBoxMaskingBehaviorBase.IsValid(string)

Implements

IAnimatable
Microsoft.Xaml.Behaviors.IAttachedObject

Extension Methods

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