Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法使用 XAML(可能还有模板绑定)来保持控件的宽度与其高度成一定比例?我希望我的控件在设计时在 Blend 中始终均匀缩放。
像下面这样的代码对我来说很好用。我一直在寻找一种更类似于 WPF 的基于模板的方法,但我认为经典方法没有任何问题。这在控件的构造函数中:
SizeChanged += ( s, e ) => Width = e.NewSize.Height * .5;