# Culture and Formatting in WPF Double TextBox

Value of `WPF Double TextBox` can be formatted in following ways:

* Culture
* NumberFormatInfo
* Dedicated properties (NumberGroupSeparator, NumberGroupSizes, NumberDecimalDigits, NumberDecimalSeparator)

## Culture based formatting

The [WPF Double TextBox](https://www.syncfusion.com/wpf-controls/double-textbox) provides support for globalization by using the [Culture](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Shared.EditorBase.html#Syncfusion_Windows_Shared_EditorBase_Culture) property. The `Culture` property is used to format the decimal separator and group separator of the `WPF Double TextBox` value based on the respective culture.

{% tabs %}
{% highlight XAML %}

<syncfusion:DoubleTextBox x:Name="doubleTextBox" Height="25" Width="150" Culture="bs-Latn" Value="1234567"/>

{% endhighlight %}
{% highlight C# %}

using Syncfusion.Windows.Shared;
using System.Globalization;

DoubleTextBox doubleTextBox = new DoubleTextBox();
doubleTextBox.Width = 150;
doubleTextBox.Height = 25;
doubleTextBox.Value = 1234567;

//Setting Latin culture for double textbox.
doubleTextBox.Culture = new CultureInfo("bs-Latn");

{% endhighlight %}
{% endtabs %}

By default the US culture uses “,” as the `NumberGroupSeparator` and "." as the `NumberDecimalSeparator`, whereas the Latin culture uses “.” as the `NumberGroupSeparator` and "," as the `NumberDecimalSeparator`.

**Default Culture**

![WPF DoubleTextBox with Default Culture](https://help.syncfusion.com/wpf/double-textbox/culture-and-number-formats-images/wpf-double-textbox-culture.jpeg)

**Latin Culture**

![WPF DoubleTextBox with Latin Culture](https://help.syncfusion.com/wpf/double-textbox/culture-and-number-formats-images/wpf-double-textbox-latin-culture.png)

## NumberFormatInfo based formatting

The number formatting of `WPF Double TextBox` can be customized by setting the [NumberFormat](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Shared.EditorBase.html#Syncfusion_Windows_Shared_EditorBase_NumberFormat) property.

{% tabs %}
{% highlight XAML %}

<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"
        xmlns:numberformat="clr-namespace:System.Globalization;assembly=mscorlib"
        x:Class="DoubleTextBoxSample.MainWindow"
        Title="DoubleTextBox Sample" Height="350" Width="525">
    <Grid>
        <syncfusion:DoubleTextBox x:Name="doubleTextBox" Height="25"
                                  Width="200" Value="1234567"
                                  GroupSeperatorEnabled = "True">
            <syncfusion:DoubleTextBox.NumberFormat>
                <numberformat:NumberFormatInfo NumberGroupSeparator="/"
                                               NumberDecimalDigits="4"
                                               NumberDecimalSeparator="*"/>
            </syncfusion:DoubleTextBox.NumberFormat>
        </syncfusion:DoubleTextBox>
    </Grid>
</Window>

{% endhighlight %}

{% highlight C# %}

using Syncfusion.Windows.Shared;
using System.Globalization;

DoubleTextBox doubleTextBox = new DoubleTextBox();
doubleTextBox.Width = 200;
doubleTextBox.Height = 25;
doubleTextBox.Value = 1234567;
doubleTextBox.GroupSeperatorEnabled = true;
doubleTextBox.NumberFormat = new NumberFormatInfo()
{
    NumberGroupSeparator = "/",
    NumberDecimalDigits = 4,
    NumberDecimalSeparator = "*"
};

{% endhighlight %}
{% endtabs %}

![WPF DoubleTextBox with Formatting](https://help.syncfusion.com/wpf/double-textbox/culture-and-number-formats-images/wpf-double-textbox-formatting.jpeg)

The following code illustrates how to set the number group size by using the `NumberFormat` property.

{% tabs %}
{% highlight C# %}

using Syncfusion.Windows.Shared;
using System.Globalization;

DoubleTextBox doubleTextBox = new DoubleTextBox();
doubleTextBox.Width = 200;
doubleTextBox.Height = 25;
doubleTextBox.Value = 123456789;
doubleTextBox.NumberFormat = new NumberFormatInfo()
{
    NumberDecimalDigits = 4,
    NumberGroupSeparator = "/",
    NumberDecimalSeparator = "*",

    // Adding the Number group size via NumberFormat property.
    NumberGroupSizes = new int[] { 2, 3, 4 }
};
{% endhighlight %}
{% endtabs %}

![WPF DoubleTextBox displays Different Group Size between Numbers](https://help.syncfusion.com/wpf/double-textbox/culture-and-number-formats-images/wpf-double-textbox-group-size.png)

## Formatting with dedicated properties

The number formatting of `WPF Double TextBox` can also be customized by setting the [NumberGroupSeparator](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Shared.DoubleTextBox.html#Syncfusion_Windows_Shared_DoubleTextBox_NumberGroupSeparator), [NumberGroupSizes](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Shared.DoubleTextBox.html#Syncfusion_Windows_Shared_DoubleTextBox_NumberGroupSizes), [NumberDecimalDigits](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Shared.DoubleTextBox.html#Syncfusion_Windows_Shared_DoubleTextBox_NumberDecimalDigits), and [NumberDecimalSeparator](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Shared.DoubleTextBox.html#Syncfusion_Windows_Shared_DoubleTextBox_NumberDecimalSeparator) properties. You can show the group separator by enabling the [GroupSeperatorEnabled](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Shared.DoubleTextBox.html#Syncfusion_Windows_Shared_DoubleTextBox_GroupSeperatorEnabled) property to `true`. The default value of `GroupSeperatorEnabled` is `false`.

The following code illustrates how to format using the `NumberDecimalSeparator`, `NumberDecimalDigits`, `NumberGroupSeparator`, and `NumberGroupSizes` properties of the `WPF Double TextBox`.

{% tabs %}
{% highlight C# %}

using Syncfusion.Windows.Shared;
using System.Globalization;

DoubleTextBox doubleTextBox = new DoubleTextBox();
doubleTextBox.Width = 150;
doubleTextBox.Height = 25;
doubleTextBox.Value = 123456789;
doubleTextBox.NumberGroupSeparator = "/";
doubleTextBox.NumberDecimalSeparator = "*";
doubleTextBox.NumberDecimalDigits = 3;

// Adding the Number group size via NumberGroupSizes property.
doubleTextBox.NumberGroupSizes = new int[] { 4, 3, 2 };

{% endhighlight %}
{% endtabs %}

![WPF DoubleTextBox with Formatting](https://help.syncfusion.com/wpf/double-textbox/culture-and-number-formats-images/wpf-double-textbox-number-format.png)

N> When you use both the `NumberFormat` and the dedicated properties (`NumberGroupSeparator`, `NumberGroupSizes`, `NumberDecimalDigits`, and `NumberDecimalSeparator`) to format the value of `WPF Double TextBox`, the dedicated properties take priority over `NumberFormat`.

N> When you use both `NumberFormat` and `Culture`, the `NumberFormat` will have a higher priority.
