私はWPFで遊び始めたばかりです。
Label のテキストのサイズまたは TextBlock のサイズ自体を親コンテナーに合わせることは可能ですか?
ありがとう、マーク
私はWPFで遊び始めたばかりです。
Label のテキストのサイズまたは TextBlock のサイズ自体を親コンテナーに合わせることは可能ですか?
ありがとう、マーク
ViewBox を使用して、コンテナ内に収まるように何かを視覚的にズームできます。ここでの他のソリューションは機能しますが、コントロールの内容ではなく、コントロールを引き伸ばすだけです。ViewBox は両方を拡大します。
<!-- Big grid, will stretch its children to fill itself -->
<Grid Width="1000" Height="1000">
<!-- The button is stretched, but its text remains teeny tiny -->
<Button>
<!-- The viewbox will stretch its content
to fit the final size of the button -->
<Viewbox
Margin="4"
VerticalAlignment="Stretch"
Height="Auto">
<!-- The textblock and its contents are
stretched to fill its parent -->
<TextBlock
Text="Bartenders" />
</Viewbox>
</Button>
</Grid>
親コンテナに依存
Grid、DockPanel はコントロールをストレッチします。StackPanel、WrapPanel はコントロールに任せてサイズを調整します。
HorizontalAlignment/VerticalAlignment を「ストレッチ」に設定します。
DockPanel を親コンテナーとして使用する
<DockPanel>
<TextBlock />
</DockPanel>