Table of Contents
  • Getting Started
  • EO.Pdf
  • EO.Web
  • EO.WebBrowser
  • EO.Wpf
    • Overview
    • Installation & Deployement
    • Skin & Theme
    • Common Taskes and Services
    • EO.Wpf Buttons
    • EO.Wpf Calendar & DatePicker
    • EO.Wpf ComboBox
    • EO.Wpf DockView
    • EO.Wpf Gauge
    • EO.Wpf ListBox
    • EO.Wpf Menu
    • EO.Wpf MaskedEdit
    • EO.Wpf ProgressBar
    • EO.Wpf Slider
    • EO.Wpf SpinEdit
    • EO.Wpf SplitView
    • EO.Wpf TabControl
    • EO.Wpf TreeView
    • EO.Wpf Utility Controls
    • EO.Wpf WindowChrome
    • Sample Data Objects
  • Common Topics
  • Reference
Customizing Value Format

EO.Wpf SpinEdit can display the current value in a custom format. This section covers the following topics:

Basic Formating

Use ValueFormat and DecimalDigits for basic formatting. For example, the following code sets ValueFormat to Currency and DecimalDigits to 2:

XAML
<Window x:Class="Test.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:eo="http://schemas.essentialobjects.com/wpf/"
        xmlns:g="clr-namespace:System.Globalization;assembly=mscorlib"
        Title="MainWindow" Height="250" Width="350">
    <StackPanel Margin="10">
        <eo:SpinEdit HorizontalAlignment="Left" Width="100" ValueFormat="Currency" DecimalDigits="2" />
    </StackPanel>
</Window>

The above code produces the following result:

Note for value 0, it displays "$0.00" instead of "0".

Advanced Formating

Alternatively, you can use a NumberFormatInfo object to customize the format. The following sample demonstrates how to use this feature:

XAML
<Window x:Class="Test.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:eo="http://schemas.essentialobjects.com/wpf/"
        xmlns:g="clr-namespace:System.Globalization;assembly=mscorlib"
        Title="MainWindow" Height="250" Width="350">
    <Window.Resources>
        <g:NumberFormatInfo x:Key="CustomValueFormat" CurrencyNegativePattern="1" CurrencySymbol="£"></g:NumberFormatInfo>
    </Window.Resources>
    <StackPanel Margin="10">
        <eo:SpinEdit HorizontalAlignment="Left" 
            Minimum="-10" Maximum="10" Value="-1" Width="100" 
            ValueFormat="Currency" NumberFormatInfo="{StaticResource CustomValueFormat}" />
    </StackPanel>
</Window>

The above code produces the following result:

Note the current symbol is changed to pound, and the negative number format has been changed to "-$n" instead of the default "($n)" format.