Geeks With Blogs
Imran Shaik Silverlight Quintessential Rambling

Skinning a ListBoxItem/Button or any content element that has its content binded to ContentPresenter and changing it foreground color  often seems impossible, the problem is ContentPresenter doesn’t have the foreground property so you can’t do much for it VisualStateManager. But there are two different ways to achieve this using a trick or hack.



Modify the template of the ListBoxItem, collapse/Remove the ContentPresenter and add a TextBlock and bind the Text property to TemplateBinding to Content, but ofcourse this would only work if the Content is Text, to apply the same for other complex templates a hack should do.



Just manually edit the ListBoxItem template and change the ContentPresenter to ContentControl, since ContentControl supports Foreground property you should be able to get the same result, and if the content template is using complex template, the template Foreground should be TemplateBinded to Foreground.

Posted on Wednesday, July 29, 2009 11:45 PM Silverlight | Back to top

Comments on this post: Changing Content Foreground from VSM

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Imran Shaik | Powered by: