0

I just wanna know that Is it possible to do something with data when the data is rendering in WPF DataGrid from the DataSet. I have stored data in database like matrix form and i want to directly attach it to the datagrid, but when the rendering process is going on for every cell, i will pick it and check, and accordingly i want to set the background color, foreground color or any designing for that cell.

Please tell me how to do it?

H.B.
  • 166,899
  • 29
  • 327
  • 400
iVad
  • 563
  • 2
  • 4
  • 13

1 Answers1

0

If you want to set the colour of the cells you'll need to use styles.

This article covers it well:

http://blogs.msdn.com/b/jaimer/archive/2009/01/20/styling-microsoft-s-wpf-datagrid.aspx

GrandMasterFlush
  • 6,269
  • 19
  • 81
  • 104
  • I know that but i want to set the style according to data, and for fast processing, i wanna do it at rendering time. Otherwise i can change style of every cell after filling data into datagrid by looping through every cell(value) then check and set styles accordingly. For that purpose, i would like to how to check every data when it is rendering. For example, in ASP.NET, there is a Repeater control, DataList control or etc are available that, one by one fetch the data and put it into the grid and if needed, then change it. So, tell me, how it is possible in WPF? – iVad Jan 23 '13 at 13:05
  • Can you give an example of a how you would like the data to affect the colours? Styles are pretty flexible. – GrandMasterFlush Jan 23 '13 at 14:22
  • 1
    @VadSoft You're going to suffer a lot if you expect WPF to work with the same mentality you bring from ASP.Net. Learn MVVM, things are not manipulated in "render-time" in WPF. – Federico Berasategui Jan 23 '13 at 16:22
  • @HighCore Thanks for suggetion...Yes, i wanna do same as ASP.Net's grid's template with WPF DataGrid. If it is possible using MVVM then tell me what is it and how to use it? Have you any example or material links that can help me. Thank you... – iVad Jan 24 '13 at 06:55
  • @VadSoft read [this answer](http://stackoverflow.com/questions/14381402/wpf-programming-methodology/14382137#14382137) for my explanation of MVVM – Federico Berasategui Jan 24 '13 at 12:59