开发者

WPF resizing TextBlock

I have a textblock in a grid in WPF.

I want the text to dynamically size (font) when resized. At the moment text开发者_如何学Pythonboxes, comboboxes do this, but the the textblock stays the same. Is it possible?


Instead of trying to manually rig a TextBlock to do this, just edit the default template of a TextBox and remove the border and background, then in the style make it set the IsReadOnly flag. This way you get the textblock sizing, as well as copy-paste for free.


You can use a ViewBox for this.

eg:

<Viewbox Stretch="Uniform">
    <TextBlock Text="Test" />
</Viewbox>


use expression blend for getting the default template of TextBox, then you can edit it as you required.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜