Click here to Skip to main content
15,896,912 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a silverlight project which contains many pages; many of them with DataGrids on them.

Throughout the project all of the DataGrids are bound to a resource which makes the style of the DataGrids the same (IE the header, body, fonts, color, spacing, and borders are the same on all the DataGrids on all the pages).

My problem, however, is that I need a couple DataGrids to have their own unique look. How can I stop this resource from being applied to these outlying DataGrids?
Posted

A simple way to do this is to create a set of templates for those DataGrids and assign keys to those templates. You can then bind the templates for the various parts to those DataGrids.
 
Share this answer
 
Copy those templates into the respective views and then modify them so that they are customized within those views.
If there is a need to reuse them across another area, move them to the resource dictionary.

Note that, AFAIK, if there is a template within the xaml and another within the resource dictionary (both having the same name), the one within the xaml gets higher precedence.
 
Share this answer
 
v3
Comments
Matt Kloss 19-Dec-11 13:22pm    
This did it for me - Thanks!

I copied / pasted the main template on to the one xaml that would have a different style and made the changes I needed to that resource. Then it was a matter of binding to my new key. Thanks for you help.
Abhinav S 19-Dec-11 13:28pm    
You are welcome.

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