Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have DataGrid whose RowBackGround and alternating RowBackGround set to black at the design time itself.
an as the part of event triggered theme change I want to include AlternatingRowBackGround and RowBackGround to be set during run time (to some other color) but it is not taking place.it require some overrid how i can aproach this
thanks in advance
Posted
Comments
Sergey Alexandrovich Kryukov 26-Jan-12 15:46pm    
Why do you think this is override? Is the property bound, and how?
--SA
Sergey Alexandrovich Kryukov 26-Jan-12 15:47pm    
Please don't re-post.
--SA

What's the problem? What's wrong with MyDataGrid.Rowbackground = someBruh;?

Please see:
http://msdn.microsoft.com/en-us/library/system.windows.controls.datagrid.rowbackground%28v=vs.95%29.aspx[^].

See also this CodeProject thread: http://beta.codeproject.com/Messages/4078126/Datagrid-Row-background-binding-issue.aspx[^].

[EDIT]

Please see the answer by Espen and our comments in his thread. Crediting Espen's note on the styles, I mentioned the article which you could find useful:
WPF Themes and Skins Engine[^].

—SA
 
Share this answer
 
v2
Comments
[no name] 26-Jan-12 15:48pm    
I have set these properties at design time to certain colors. and during run time I set RowBackground to some brush in the AutoGeneratecolumn event handler. but it do not have any effect.
Sergey Alexandrovich Kryukov 26-Jan-12 16:26pm    
Well, how do you know this code was called? Put a break point on it.
--SA
Espen Harlinn 26-Jan-12 16:10pm    
5'ed! Wayne Gaylard reply to the thread you referenced should work nicely:
http://beta.codeproject.com/Messages/4078525/Re-Datagrid-Row-background-binding-issue.aspx
Sergey Alexandrovich Kryukov 26-Jan-12 16:25pm    
Thank you, Espen.
--SA
Have a look at:Styling Microsoft’s WPF datagrid[^]

Rembemer that styles can be inherited[^] too.

Create new styles for your application that inherits from the ones you want to work with your application and apply appropriate setters. This way you will not need to handle any events in your application.

WPF DataGrid Practical Examples[^] provides a good introduction to the WPF DataGrid.

Best regards
Espen Harlinn
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 26-Jan-12 16:32pm    
This is very appropriate, my 5.

So, maybe OP should review the design instead of just straightforward manipulation with the property (which he failed to achieve so far, please see his comment to my answer).
--SA
Sergey Alexandrovich Kryukov 26-Jan-12 16:36pm    
By the way, as to the last links: if I'm not mistaken, OP asked for a book or a site about this very control, and you appreciated my answer (very general though). Maybe this relatively short and nice article will serve as a book or a Web site for OP... :-)

Another 5... Oops! despite of the beta version of the site, only one 5 is taken into account. :-)
--SA
Espen Harlinn 26-Jan-12 16:41pm    
Thank you, Sergey!
Personally I think deriving from existing styles would be in line with the design philosophy of WPF :)
Sergey Alexandrovich Kryukov 26-Jan-12 17:08pm    
Good style system should be cascading. I recently referenced a CodeProject article where the author introduced pretty much universal systems to support WPF skins. As far as I understand, it is nice and mature work; and it is inline with the design philosophy you mentioned.

It would take some time to find it on CodeProject again...
--SA
Espen Harlinn 26-Jan-12 17:11pm    
Pity, I'd like a link to that article ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900