WPF Currency TextBox
The Syncfusion WPF CurrencyTextBox is a specialized input control that restricts entry to decimal values and displays them in currency format. It provides comprehensive support for data binding, culture-specific formatting, value validation, watermarks, null values, and extensive customization options.
When to Use This Skill
Use this skill when implementing WPF applications that require:
- Currency input fields for financial applications, invoicing, pricing, or e-commerce
- Formatted decimal entry with automatic currency symbols and separators
- Culture-specific formatting for international applications
- Value validation with minimum/maximum restrictions
- Custom number formatting with specific decimal digits, group separators, or currency symbols
- Data-bound currency fields in MVVM applications
- Styled financial inputs with foreground colors for positive/negative/zero values
- Increment/decrement controls using keyboard arrows, mouse wheel, or spin buttons
- Read-only currency displays with formatted values
- Visual progress indicators for currency values within a range
Component Overview
Key Capabilities:
- Restricts input to decimal values only
- Automatic currency formatting with culture support
- Min/Max value validation with configurable validation modes
- Data binding support for MVVM patterns
- Custom formatting via Culture, NumberFormatInfo, or dedicated properties
- Step interval for keyboard/mouse wheel navigation
- Foreground colors for positive, negative, and zero values
- Watermark and null value support
- Range adorner for visual progress indication
- Spin buttons for value increment/decrement
- Paste mode with advanced insertion behavior
Documentation and Navigation Guide
Getting Started
📄 Read: references/getting-started.md
- Assembly deployment and NuGet package installation
- Adding CurrencyTextBox via designer, XAML, or C#
- Setting and binding the Value property
- Value changed notification and event handling
- Basic min/max value restrictions
- Introduction to step interval and culture support
Formatting and Culture
📄 Read: references/formatting-culture.md
- Culture-based formatting for international applications
- NumberFormatInfo configuration (separators, symbols, decimal digits)
- Dedicated formatting properties (CurrencySymbol, CurrencyGroupSeparator, etc.)
- Currency group sizes and patterns
- Positive and negative value patterns
- Format property precedence and priority rules
Validation and Restrictions
📄 Read: references/validation-restrictions.md
- Min/Max value restrictions and validation modes
- OnKeyPress vs OnLostFocus validation
- MaxValueOnExceedMaxDigit and MinValueOnExceedMinDigit behavior
- Decimal digit restrictions (min/max decimal places)
- Read-only mode with caret visibility options
Step Interval and Scrolling
📄 Read: references/step-interval-scrolling.md
- ScrollInterval property for increment/decrement amounts
- Arrow key navigation (up/down)
- Mouse wheel scrolling with IsScrollingOnCircle
- Click-and-drag scrolling with EnableExtendedScrolling
- Text selection on focus behavior
Appearance and Styling
📄 Read: references/appearance-styling.md
- Foreground colors for positive, negative, and zero values
- Background customization
- Corner radius for rounded borders
- Selection brush and opacity
- Text alignment (left, center, right)
- Tooltip configuration
Advanced Features
📄 Read: references/advanced-features.md
- Null values with UseNullOption and NullValue
- Watermark text, templates, and styling
- Paste mode (Default vs Advanced)
- Spin buttons (ShowSpinButton) for UpDown controls
- Range adorner for visual progress indicators
- Value changed event handling
Quick Start Example
XAML Implementation
xml
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:syncfusion="http://schemas.syncfusion.com/wpf">
<StackPanel Margin="20">
<!-- Basic currency input -->
<syncfusion:CurrencyTextBox
x:Name="currencyTextBox"
Width="200"
Height="30"
Value="1234.56" />
<!-- With min/max validation -->
<syncfusion:CurrencyTextBox
Width="200"
Height="30"
Value="500"
MinValue="0"
MaxValue="10000"
ScrollInterval="50" />
</StackPanel>
</Window>
C# Implementation
csharp
using Syncfusion.Windows.Shared;
// Create instance
CurrencyTextBox currencyTextBox = new CurrencyTextBox();
currencyTextBox.Width = 200;
currencyTextBox.Height = 30;
// Set value
currencyTextBox.Value = 1234.56;
// Configure validation
currencyTextBox.MinValue = 0;
currencyTextBox.MaxValue = 10000;
// Set culture for formatting
currencyTextBox.Culture = new System.Globalization.CultureInfo("en-US");
// Handle value changes
currencyTextBox.ValueChanged += (d, e) =>
{
var oldValue = e.OldValue;
var newValue = e.NewValue;
};
// Add to layout
this.Content = currencyTextBox;
Common Patterns
Basic Currency Input with Validation
xml
<syncfusion:CurrencyTextBox
x:Name="priceInput"
Width="150"
Height="30"
Value="99.99"
MinValue="0"
MaxValue="9999.99"
ScrollInterval="10"
ToolTip="Enter product price" />
Formatted Currency with Culture
csharp
CurrencyTextBox currencyTextBox = new CurrencyTextBox();
currencyTextBox.Value = 1234567.89;
currencyTextBox.Culture = new CultureInfo("fr-FR"); // French formatting
// Result: 1 234 567,89 €
Custom Currency Symbol and Formatting
csharp
CurrencyTextBox currencyTextBox = new CurrencyTextBox();
currencyTextBox.Value = 123456.789;
currencyTextBox.CurrencySymbol = "£";
currencyTextBox.CurrencyDecimalDigits = 2;
currencyTextBox.CurrencyGroupSeparator = ",";
currencyTextBox.CurrencyDecimalSeparator = ".";
currencyTextBox.GroupSeperatorEnabled = true;
// Result: £123,456.79
Data Binding with MVVM
XAML:
xml
<syncfusion:CurrencyTextBox
Value="{Binding Price, UpdateSourceTrigger=PropertyChanged}"
MinValue="0"
MaxValue="100000"
Width="150"
Height="30" />
ViewModel:
csharp
public class ProductViewModel : INotifyPropertyChanged
{
private double _price;
public double Price
{
get => _price;
set
{
_price = value;
OnPropertyChanged(nameof(Price));
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
Styled with Color-Coded Values
xml
<syncfusion:CurrencyTextBox
x:Name="profitLoss"
Width="150"
Height="30"
Value="-250.00"
PositiveForeground="Green"
NegativeForeground="Red"
ApplyNegativeForeground="True"
ZeroColor="Gray"
ApplyZeroColor="True" />
Currency Input with Spin Buttons
xml
<syncfusion:CurrencyTextBox
Width="150"
Height="30"
Value="100"
MinValue="0"
MaxValue="1000"
ScrollInterval="25"
ShowSpinButton="True" />
With Watermark for Empty State
xml
<syncfusion:CurrencyTextBox
Width="150"
Height="30"
UseNullOption="True"
WatermarkText="Enter amount"
WatermarkTextIsVisible="True"
WatermarkTextForeground="Gray" />
Key Properties Reference
Essential Properties
| Property | Type | Description |
|---|
| | Gets or sets the currency value. Use this instead of property. |
| | Minimum allowed value. |
| | Maximum allowed value. |
| | Culture for formatting decimal and group separators. |
| | Increment/decrement amount for arrow keys and mouse wheel. Default: 1. |
Formatting Properties
| Property | Type | Description |
|---|
| | Currency symbol to display (e.g., "$", "€", "£"). |
| | Number of decimal places. Default: -1 (culture default). |
| | Decimal separator character (e.g., ".", ","). |
| | Group separator for thousands (e.g., ",", " "). |
| | Sizes of digit groups (e.g., {3} for thousands). |
| | Enables display of group separator. |
| | Complete number format configuration object. |
| | Pattern for positive values (0-3). See formatting reference. |
| | Pattern for negative values (0-15). See formatting reference. |
Validation Properties
| Property | Type | Description |
|---|
| | When to validate minimum: or . |
| | When to validate maximum: or . |
| | Set to MaxValue when input exceeds maximum. |
| | Set to MinValue when input is below minimum. |
MinimumCurrencyDecimalDigits
| | Minimum decimal places to display. |
MaximumCurrencyDecimalDigits
| | Maximum decimal places allowed. |
| | Prevents user input when true. |
| | Shows caret in read-only mode. |
Appearance Properties
| Property | Type | Description |
|---|
| | Foreground color for positive values. Default: Black. |
| | Foreground color for negative values. Default: Red. |
| | Enables negative foreground color. |
| | Foreground color when value is zero. Default: Green. |
| | Enables zero color. |
| | Background color of the control. |
| | Corner radius for rounded borders. Default: 1. |
| | Text alignment: Left, Center, or Right. |
| | Background color for selected text. |
| | Opacity of selection brush. |
Scrolling Properties
| Property | Type | Description |
|---|
| | Enables mouse wheel scrolling. Default: true. |
| | Enables click-and-drag scrolling. |
| | Auto-selects text when control receives focus. Default: true. |
Advanced Properties
| Property | Type | Description |
|---|
| | Enables null value and watermark support. |
| | Value to display when control is null. |
| | Text to display when value is null/empty. |
| | Shows/hides watermark. |
| | Foreground color for watermark. |
| | Custom template for watermark appearance. |
| | Paste behavior: or . |
| | Shows UpDown spin buttons. |
| | Shows visual progress indicator based on min/max. |
| | Background color of range adorner. |
Events
| Event | Description |
|---|
| Raised when the Value property changes. Provides OldValue and NewValue. |
Common Use Cases
- E-commerce Product Pricing - Currency input with validation for product prices
- Financial Calculators - Loan amounts, interest rates, payment calculations
- Invoicing Systems - Line items, subtotals, tax amounts, totals
- Budgeting Applications - Expense tracking, budget allocation, balance display
- Point of Sale Systems - Transaction amounts, discounts, change calculation
- International Applications - Multi-currency support with culture-specific formatting
- Accounting Software - General ledger entries, balance sheets, financial reports
- Payroll Systems - Salary entry, deductions, net pay calculation
- Inventory Management - Cost tracking, pricing, valuation
- Donation Forms - Contribution amounts with preset increments
Notes
- Always use property, not , to get/set the currency amount
- Format priority: Dedicated properties > NumberFormat > Culture
- Validation modes: OnKeyPress prevents invalid input; OnLostFocus validates after entry
- Range adorner only displays when both MinValue and MaxValue are set
- Watermark only appears when UseNullOption is true and value is null/empty