RB Davidson
RB Davidson

Reputation: 628

Data Annotations not working

I am new to Silverlight 4.0 building a business application. I have tried ussing some of the Data Annotation attributes with both the DataForm and the DataGrid. The Display and Editable attributes work without a problem, but DisplayFormat seems to be ignored. Am I missing something or are these attributes not supported by the DataGrid and DataForm?

Upvotes: 1

Views: 448

Answers (1)

Keith Adler
Keith Adler

Reputation: 21178

DisplayFormat is not picked up by the Silverlight controls. If you wanted to control the display format you could either use the StringFormat on the Binding or a custom converter built against the IValueConverter interface. Most likely you will do something like this:

<sdk:DataGridTextColumn Header="Cost" Binding="{Binding Path=Cost, StringFormat=\{0:c\}}" />  

Upvotes: 1

Related Questions