# MaskedCurrencyInput

The **RadMaskedCurrencyInput** represents the basic control that can be used to restrict the input of currency values.

In order to use the **RadMaskedCurrencyInput** control in your projects you have to add references to the following assemblies:

* **Telerik.Licensing.Runtime**
* **Telerik.Windows.Controls**
* **Telerik.Windows.Controls.Input**
* **Telerik.Windows.Data**

You can find more info [here](http://www.telerik.com/help/wpf/installation-installing-controls-dependencies-wpf.html).

> tip With the 2025 Q1 release, the Telerik UI for WPF has a new licensing mechanism. You can learn more about it [here](https://www.telerik.com/products/wpf/documentation/installation/licensing/installing-license-key).

## Declaratively defined MaskedCurrencyInput

Here is a simple definition of a **RadMaskedCurrencyInput** control:

**Example 1: Define RadMaskedCurrencyInput in XAML**

```XAML
<telerik:RadMaskedCurrencyInput Width="200"
	                                Margin="20 20 20 10"
	                                Culture="en-US"
	                                EmptyContent="Enter digits"
	                                InputBehavior="Replace"
	                                Mask="#9.2"
	                                SelectionOnFocus="SelectAll"
	                                TextMode="PlainText"
	                                UpdateValueEvent="LostFocus"
	                                Value="12345.67" />
```

![WPF RadMaskedInput Default Currency](https://www.telerik.com/products/wpf/documentation/assets/271105011643006b79fed313898c286b/radmaskedinput_currencyinput_default.png)

You can further customize the **RadMaskedCurrencyInput** control's behavior by setting the IsCurrencySymbolVisible property to False thus hiding the culture specific currency symbol. By default this property is set to True.

## Properties

* **Value**: A property of type **decimal?** that gets or set the current value of the control.
* **AutoFillNumberGroupSeparators**: A boolean property that gets or sets whether number group separators are auto filled in the mask.
* **AutoFillZeros**: A boolean property that gets or sets whether trailing zeros should be auto filled.
* **AllowSkipPlaceholders**: A boolean property that gets or sets whether input can skip placeholders.
* **IsCurrencySymbolVisible**: A boolean property that gets or sets whether the currency symbol is visible or not. Default value is **True**.

## Data Binding

RadMaskedCurrencyInput's **Value** property is of type **nullable decimal (decimal?)** and you have to bind it to ViewModel's property of type decimal or nullable decimal (if you need to set null).

> important Binding to **object** is not support and may result in unpredictable behavior.

**Example 2: Define the view model**

```C#
public class ViewModel : ViewModelBase
{
    private decimal? amount;

    public ViewModel()
    {
        this.Amount = 12345.67m;
    }

    public decimal? Amount
    {
        get { return this.amount; }
        set
        {
            if (this.amount != value)
            {
                this.amount = value;
                this.OnPropertyChanged("Amount");
            }
        }
    }
}
```

**Example 3: Binding the Value property**

```XAML
<telerik:RadMaskedCurrencyInput Culture="en-US"
								   InputBehavior="Replace"
								   Mask="#9.2"
								   TextMode="PlainText"
								   UpdateValueEvent="LostFocus"
								   Value="{Binding Amount,Mode=TwoWay}" />
```

## FormatString

You can further format the entered value by setting the **FormatString** property. It uses [Standard Numeric Format Strings](http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx) and [Custom Numeric  Format Strings](http://msdn.microsoft.com/en-us/library/0c899ak8.aspx) to further format the **Text** property.

### FormatString with Mask

When **Mask** property is set the **FormatString** property will be applied to the **Text** property of MaskedCurrencyInput control.

**Example 4: Setting the FormatString property in Mask scenario**

```XAML
<telerik:RadMaskedCurrencyInput Culture="en-US" x:Name="currencyInput" Width="200"
								   EmptyContent="Enter digits"
								   FormatString="n3"
								   Mask="#9.2"
								   TextMode="PlainText"
								   UpdateValueEvent="PropertyChanged"
								   Value="12345.56" />
<StackPanel>
    <StackPanel Orientation="Horizontal">
        <TextBlock Text="Text is: "/>
        <TextBlock Text="{Binding Text,ElementName=currencyInput}"/>
    </StackPanel>
    <StackPanel Orientation="Horizontal">
        <TextBlock Text="Value is: "/>
        <TextBlock Text="{Binding Value,ElementName=currencyInput}"/>
    </StackPanel>
</StackPanel>
```

![WPF RadMaskedInput Format String with Mask](https://www.telerik.com/products/wpf/documentation/assets/1729568379018ce319514afb57c3f4f3/radmaskedinput_currencyinput_format_string_withmask.png)

### FormatString with No-Mask

In **No-Mask** scenario the **FormatString** property will be applied to the **Value** property of MaskedNumericInput control.

**Example 5: Setting the FormatString property**

```XAML
<telerik:RadMaskedCurrencyInput HorizontalAlignment="Center"
	                                EmptyContent="Enter currency"
	                                Culture="en-US"
	                                FormatString="n3"
	                                UpdateValueEvent="LostFocus"
	                                SpinMode="PositionAndValue" 
	                                Value="123456"/>
```

![WPF RadMaskedInput Format String with No Mask](https://www.telerik.com/products/wpf/documentation/assets/20826cf4d45b7bc9ef872bfc3af7c68c/radmaskedinput_currencyinput_format_string.png)

## See Also

* [Getting Started](https://www.telerik.com/products/wpf/documentation/controls/radmaskedinput/getting-started)
* [MaskedNumericInput](https://www.telerik.com/products/wpf/documentation/controls/radmaskedinput/features/maskedinput-controls/numeric)
* [MaskedTextInput](https://www.telerik.com/products/wpf/documentation/controls/radmaskedinput/features/maskedinput-controls/text)
* [MaskedDateTimeInput](https://www.telerik.com/products/wpf/documentation/controls/radmaskedinput/features/maskedinput-controls/datetime)
* [Common Features](https://www.telerik.com/products/wpf/documentation/controls/radmaskedinput/features/common)
