LoginSignup
2
1

More than 3 years have passed since last update.

【WPF】Button内テキストをButtonサイズに合わせて変更する

Posted at

はじめに

WPFでリサイズ可能なウィンドウ内にボタンを置いた時に
ボタンサイズに応じてテキストサイズも変更する方法。
テキストだけでなく、ボタン内ボタンとかでも大丈夫。(めったに無いと思うけど・・)

ViewBoxの存在を知らなかったので
もし同じような人がいたら、ということで。

方法

MainWindow.xaml
<Window ~~~ 省略 ~~~ >
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Button Grid.Row="0">
            <Viewbox>
                <TextBlock>可変サイズ</TextBlock>
            </Viewbox>
        </Button>
        <Button Grid.Row="1">
            サイズ固定
        </Button>
    </Grid>
</Window>

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1