Category / Section
How to format the display text as currency in WinRT NumericUpDown?
1 min read
To format the display text in the various format in SfNumericUpDown control, the FormatString property can be used. The following code snippet shows how to set the format string in currency format
XAML:
<Page x:Class="App4.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:App4" xmlns:navigation="using:Syncfusion.UI.Xaml.Controls.Navigation" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:syncfusion="using:Syncfusion.UI.Xaml.Controls.Input" xmlns:Media="using:Syncfusion.UI.Xaml.Controls.Media" xmlns:input="using:Syncfusion.UI.Xaml.Controls.Input" xmlns:converters="using:Syncfusion.UI.Xaml.Converters" mc:Ignorable="d"> <Page.Resources> <converters:ColorToBrushConverter x:Key="brushconverter1"/> </Page.Resources> <Grid x:Name="Grid1" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <input:SfNumericUpDown x:Name="numericUpDown" HorizontalAlignment="Center" VerticalAlignment="Center" Width="200" FormatString="C" Value="123.45"/> </Grid> </Page>
C#:
using Syncfusion.UI.Xaml.Controls.Input; // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238 namespace App4 { /// <summary> /// An empty page that can be used on its own or navigated to within a Frame. /// </summary> public sealed partial class MainPage : Page { public MainPage() { this.InitializeComponent(); SfNumericUpDown numericupdown = new SfNumericUpDown(); numericupdown.Width = 200; numericupdown.HorizontalAlignment = HorizontalAlignment.Center; numericupdown.VerticalAlignment = VerticalAlignment.Center; numericupdown.FormatString = "C"; numericupdown.Value = 123.45; Grid1.Children.Add(numericupdown); } } }
Output:
The following output shows the value of NumericUpDown in currency format.