2016-09-03 4 views
0

ボタンのTextBlockをプログラマチックに変更したいが、それでも正しいとはいえない。スタイルのテキストブロックボタンのテキストを変更する

<Style x:Key="RoundedButtonStyle" TargetType="Button"> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate> 
        <Border CornerRadius="50" Background="#463190"> 
         <TextBlock Text="{Binding Tag}" Foreground="White" 
            VerticalAlignment="Center" 
            HorizontalAlignment="Center"           
            Margin="0,0,0,0"          
            FontSize="20"/> 
        </Border> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 
+1

あなたの投稿を改善してください。現在の質問は含まれていません。 "私はまだそれを正しく得られませんでした"は、目的が何であり、何が問題なのかを説明していません – ASh

+0

達成したいことに関する情報を追加してください。 – ViVi

答えて

0

ButtonコントロールのテキストやTagを使用する必要はありませんを表示するプロパティContentを持っています。物事はもっと複雑になります。

あなたBinding以下に変更した場合は

、あなたは TextBlockTextを変更する ButtonContentプロパティを使用することができるようになります。

Text = "{Binding Path=Content, 
     RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}}" 
関連する問題