I'm very new in C# I tried almost evrything by searching all the web for answer, but still can't do it by myself. My question is about formating textbox
all i want is that when I writing a number in the textbox, the textbox will show this number with decimal and currency symbol.
and because i have 10 textbox that presenting numbers as currency i understand that i must do binding.
Sorry for my english.
here is my class converter
class Bindings : IvalueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value !=null)
{
double valueshop = (double)value;
return string.Format(culture, "{0:C}", valueshop;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
this is my xaml
<window.Resources>
<local:Bindings x:Key="ForText"/>
</window.Resources>
<StackPanel Margin="10">
<TextBox Name="MoneyOne" Text="{Binding Converter={StaticResources ForText}, Mode=OneWay, Path=valueshop, UpdateSourceTrigger=PropertyChanged, StringFormat='C'}"/>
</StackPanel>
I hope somebody can help, thanks.