views:

1098

answers:

3

I am trying out new styles with silverlight, and I created a new button skin with blend that consists of a border and a textblock. Wondered if there is a way to change the the text of the textblock when the the button's content(text) property is changed.

A: 

I don't really get what your trying to do. Normally, you include a TextBlock like that as a part of the button content.

mdm20
Button content as in the button text.
Drahcir
+1  A: 

The binding would look like this:

<TextBlock Text="{TemplateBinding Content}"/>

The problem is when I try to set the content to something other than text:

    <Button>
     <Button.Content>
         <Rectangle Fill="#FFB51111"/>
     </Button.Content>
 </Button>

In this case using the ContentPresenter would work better. It uses the same binding expression, but can display more than text. But all that is really up to you.

McAravey
A: 

Use a ContentPresenter rather than a TextBlock in your Template.

Gordon Mackie JoanMiro