tags:

views:

147

answers:

2

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.

A: 

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
A: 

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.

http://stackoverflow.com/questions/1417004/how-to-relative-scale-size-of-user-control/1417342#1417342

Trainee4Life