I have a wpf datagrid (.NET 4.0) that contains raw data from a database, and some of the fields need to b开发者_JAVA百科e formatted to display in a meaningful manner, for example 3 fields containing Year / Month / Day could be formatted together to produce a properly formatted date field.
Is there a nice way of doing this ?
Separate your View/XAML from your ViewModel, and keep your formatting in the ViewModel as this doesnt belong in the View!
then you can bind your date field to your datagrid and not mess up your XAML or code-behind.
If you look for a good framework to help you keep this design I recommend looking at MVVM Light or Caliburn.Micro
You scould not bInd directly you data, but you have to create a function on your model and then bind the function on you view
精彩评论