views:

65

answers:

1

Is there a way, using XAML (and possibly Template Bindings) to keep a control's width in a certain proportion to its height? I would like for my control, at design time in Blend, to always scale evenly.

A: 

Code like the following is working fine for me. I had been looking for a more WPF-ish template-based approach, but I suppose there's nothing wrong with the classic approach. This goes in the constructor of the control:

SizeChanged += ( s, e ) => Width = e.NewSize.Height * .5;
Dov