John Michaels
John Michaels

Reputation: 685

WPF - Make two controls the same size

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.

Upvotes: 1

Views: 1715

Answers (1)

Muad'Dib
Muad'Dib

Reputation: 29216

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

Upvotes: 3

Related Questions