开发者

WPF - Make two controls the same size

开发者 https://www.devze.com 2022-12-22 20:42 出处:网络
Is there any way to make two controls that are in different containers the same size in WPF?For example, suppose you have two textboxes: textbox1 and textbox2.Textbox1 is in a grid and its size can gr

Is there any way to make two controls that are in different containers the same size in WPF? For example, suppose you have two textboxes: textbox1 and textbox2. Textbox1 is in a grid and its size can grow and shrink when the user resizes the window开发者_高级运维. Textbox2 is in another part of the window and I need it to always have the same size as textbox1. Is there any way to do this?

Keep in mind SharedSizeGroup will not work because the textboxes are in different containers. Also, I've tried binding textbox2's height property to textbox1 and that doesn't seem to work either. Finally, I tried catching textbox1's SizeChanged event, but its Height property is always NaN for some reason.


You should bind to ActualWidth and ActualHeight members of the TextBox.

0

精彩评论

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