hi there is xaml code but it doesn't work

<Grid Name="mainGrid" Background="#EEE"> <Grid.RowDefinitions> <RowDefinition Height="25*"/> <RowDefinition Height="60*" Name="mainGridcentre"/> <RowDefinition Height="15*"/> </Grid.RowDefinitions> <Grid Name="centerGrid" Grid.Row="1" Background="Black" Panel.ZIndex="1" Width="{Binding ElementName=mainGridcentre, Path=Height}" ShowGridLines="True"> <Grid.RowDefinitions> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition></ColumnDefinition> <ColumnDefinition></ColumnDefinition> <ColumnDefinition></ColumnDefinition> <ColumnDefinition></ColumnDefinition> <ColumnDefinition></ColumnDefinition> </Grid.ColumnDefinitions> </Grid> <Border Grid.Row="1" Background="#14BDAC"></Border> <Label FontWeight="Bold" Background="#14BDAC" Width="200" Height="50" Content="НАЧАТЬ ЗАНОВО" Grid.Row="2" FontSize="20" FontStyle="Normal" Foreground="White" ForceCursor="True" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"></Label> </Grid> 

namely, the binding of the width to the row height of another grid does not work

 Width="{Binding ElementName=mainGridcentre, Path=Height}" ShowGridLines="True" 
  • 3
    "not working" - not rabbit? rabbits? - Igor
  • one
  • You have a Grid called mainGrid while you are trying to bind to mainGridcentre ? - Ev_Hyper
  • Well, try to tie to ActualHeight - Ev_Hyper
  • No, you didn’t understand, I don’t need the height of the grid, but the height of the 2 lines of the grid - Sasuke

1 answer 1

Replace Height with ActualHeight in binding:

 Width="{Binding ElementName=mainGridcentre, Path=ActualHeight}" 

Read more about RowDefenition.ActualHeight here .

  • And add Mode to the binding. Yes, and it should work fine with mode if the Width bind. - Max.