开发者

Formatting contents of a datagrid

开发者 https://www.devze.com 2023-01-29 02:42 出处:网络
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 Y

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

0

精彩评论

暂无评论...
验证码 换一张
取 消