3

I have Textboxes in a Grid with numbers in it. If I resize the window, I want to change the FontSize too.

This code works with the actual height of the TextBox:

<TextBox FontSize="{Binding Path=ActualHeight, RelativeSource={RelativeSource Self},
         Converter={StaticResource HeightToFontSizeConverter}}" Text="12345"/>

But now the FontSize only resizes in one direction.

Is there a possibility to bind two paths? Or another option?

Thank you.

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
user172701
  • 41
  • 2
  • 4
  • "But the Fontsize only resizes in one direction." Please clarify which direction. – Rap Sep 17 '09 at 13:59

2 Answers2

3

If you want scalable TextBox, or any other control, wrap it in to ViewBox. It defines a content decorator that can stretch and scale a single child to fill the available space.

Like:

<Viewbox>
  <Button>Button</Button>
</Viewbox>

HTH

gimalay
  • 493
  • 3
  • 9
0

A two binding in your case would be that setting the FontSize would affect the Height of the TextBox. But that my friend, ain't gonna happen! ActualHeight is a read only property.

public double ActualHeight { get; }

Also, do take a look at this reply.

How to relative scale size of User Control?

Community
  • 1
  • 1
Trainee4Life
  • 2,203
  • 2
  • 22
  • 38