Auto resizing font in WPF? [duplicate]
Possible Duplicate:
WPF 4: Grow/Shrink TextBlock (Font Size) based on available space
I ma looking for a following behaviours in WPF: All the TextBlock in my app are shown in the 24 Font size, but if there isn't enough space I would to decrease a font size.
I thought of two solutions, but none of them work:
- Put a textBox inside viewbox. Doesn't work, as all labels start to get different sizes.
- If that would be a button I would specify a MinWidth instead of Width, but there is no property called MinFontSize on the TextBlock. Edit:
- Create a custom control with property MinTextWidth (this might work)
Any other solutions, which would work?
I would say this is a design issue, if the user can't see the entire item, shrinking the text will probably not help as it may make it unreadable.
You should think about doing something where either the TextBlock grows to fit the text, or your use an expander or something to allow them to see the rest of the text.
I think there isn't generic solution for this issue. There is one simple way: layout root for your window is ViewBox
. Another way, by my opinion, is to write custom control and dynamically change ScaleTransform
(not FontSize
- this might causes perfomance issues).
精彩评论