mmmm
mmmm

Reputation: 2471

Formatting contents of a datagrid

I have a wpf datagrid (.NET 4.0) that contains raw data from a database, and some of the fields need to be 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 ?

Upvotes: 0

Views: 80

Answers (2)

user523650
user523650

Reputation:

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

Upvotes: 1

Marco Leo
Marco Leo

Reputation: 516

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

Upvotes: 0

Related Questions