2011-12-06 8 views
0

私はTextBlockのは、ボタンのコンテンツ毎回から読みたい本読書Contentプロパティ

<Style x:Key="ButtonStyle" 
       BasedOn="{x:Null}" 
       TargetType="{x:Type Button}"> 
    <Setter Property="Template"> 
     <Setter.Value> 
      <ControlTemplate TargetType="{x:Type Button}"> 
       <Grid> 
        <Rectangle x:Name="rectangle" 
           Fill="#FF04822A" 
           Stroke="{x:Null}" /> 
        <TextBlock HorizontalAlignment="Center" 
           VerticalAlignment="Center" 
           FontWeight="Heavy" 
           Foreground="Black" 
           x:Name="btnText" 
           TextAlignment="Center" /> 
       </Grid> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
</Style> 
<Button Grid.Row="3" 
       Grid.Column="5" 
       Margin="4,0,4,0" 
       Command="{Binding ResetCommand}" 
       Content ="Reset Cells" 
       Style="{StaticResource ButtonStyle}" /> 

のようなControlTemplateの何かとボタンのスタイルを持っていますその更新された。

答えて

3

TextBlockに結合するテンプレートを追加します。

Text="{TemplateBinding Content}" 

あなただけ(TextBlocks通常のみ表示テキストなど)ものの代わりにContentPresenterを使用する場合があります。

関連する問題