This is a migrated thread and some comments may be shown as answers.

Getting a FormatString threw an exception

1 Answer 321 Views
MaskedInput (Numeric, DateTime, Text, Currency)
This is a migrated thread and some comments may be shown as answers.
Rod
Top achievements
Rank 1
Rod asked on 09 Jul 2013, 05:14 PM
I've placed a masked numeric input control onto a user control we're working on. When I run the app I get the following error:

System.Windows.Markup.XamlParseException occurred
  HResult=-2146233087
  Message='Set property 'Telerik.Windows.Controls.RadMaskedInputBase.FormatString' threw an exception.' Line number '291' and line position '48'.
  Source=PresentationFramework
  LineNumber=291
  LinePosition=48
  StackTrace:
       at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
  InnerException: System.FormatException
       HResult=-2146233033
       Message=Format specifier was invalid.

I'm sure I've done something wrong, but am not sure what. Here's what the XAML looks like right now:

<telerik:RadMaskedNumericInput x:Name="txtClientNumber" FormatString="D6" MinWidth="80" Margin="3,0"
                               VerticalContentAlignment="Center" FontSize="15"
                               Value="{Binding ClientNumber, UpdateSourceTrigger=PropertyChanged}" Mask="#6" />

What we're trying to do is have the user enter a 6 digit integer value. The data type is an int (in C#), and SQL Server data type is also an int. So, what's the error of my ways?

1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 11 Jul 2013, 11:00 AM
Hi Rod,

FormatString determines the way you see the calue in the MaskedInput control when it is not focused.
For example, with FormatString = "{}{0:n1}"
The focused control will display 123456 and the unfocused: 123456.0
So I guess you nedd FormatString = "{}{0:n0}" which will display 123456 in both cases. One of your mistakes is the correct format of the string and the other is using D instead of N.
Additionaly, you may have to set AutoFillNumberGroupSeparators="False" to remove the separator.
Let us know if this moves you in the right direction.

Regards,
Petar Mladenov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
MaskedInput (Numeric, DateTime, Text, Currency)
Asked by
Rod
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Share this question
or