WPF: Binding the height of a component to another's
Bind to the ActualHeight
rather than the Height
property:
<RowDefinition Height="{Binding ActualHeight, ElementName=otherTextBox}" />
Put the two grids in a shared size scope, and use SharedSizeGroup
to lock the row heights together:
<SomeContainer Grid.IsSharedSizeScope="True"> <!-- Could be the Window or some more nearby Panel --> <Grid> <Grid.RowDefinitions> <RowDefinition SharedSizeGroup="LabelAndRadioButtonGroup" /> </Grid.RowDefinitions> <Label Grid.Row="0" /> </Grid> <Grid> <Grid.RowDefinitions> <RowDefinition SharedSizeGroup="LabelAndRadioButtonGroup" /> </Grid.RowDefinitions> <RadioButton Grid.Row="0" /> </Grid></SomeContainer>
See also How to: Share sizing properties between grids in MSDN.