-4

I am new to MVVM and cannot determine how I convert datetime values to short date time so they display correctly in my datagrid.

Can anyone provide some sample code to convert datetime to short date time correctly?

JoshDM
  • 4,837
  • 7
  • 43
  • 72

1 Answers1

2

Your ViewModel is not supposed to specify how it is being displayed in the view. So your ViewModel just has a property with the DateTime object.

The actual formatting is then specified in the view; with WPF you do that in the binding with the StringFormat parameter:

{Binding MyDate, StringFormat=d}
poke
  • 339,995
  • 66
  • 523
  • 574