开发者

Setting a custom control's aspect ratio

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 tim开发者_如何学运维e in Blend, to always scale evenly.


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;
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜