Search This Blog

Mind freaker Stuff

Please Visit my new blog http://www.mindfreakerstuff.com for new articles related to web and mobile designing.

Tuesday, September 20, 2011

Contentpresenter Foreground, Font-Size, Font-Family Change inside Style (WPF / XAML)

To change Font Size, Foreground or Font Family

1) Directly Assign Property to Content-presenter 
 - XAML
<ContentPresenter TextBlock.FontFamily="Tahoma"
                  TextBlock.FontWeight="Bold"
                  TextBlock.Foreground="Red"
                  VerticalAlignment="Center"
                  RecognizesAccessKey="True" />
 
  OR

2)Adding Setter To the Style-
                      <Trigger Property="IsSelected" Value="true">
     <Setter Property="TextBlock.Foreground" TargetName="TabHeadetText"     Value="white"/>
     <Setter Property="TextBlock.FontFamily" TargetName="TabHeadetText"     Value="Tahoma"/>
</Trigger>


3 comments:

  1. Hello,

    I did this, and I got run time error: textblock doesn't have attached properity fontfamily ??!

    Can you help me in this

    Best regards

    ReplyDelete
    Replies
    1. hi Waleed,

      Above code can be apply to "ContentPresenter" of Button or Tab button.
      Please check out following example

      WpfApplication1.zip

      WpfApplication1Setter.zip

      Delete