There is the following markup in wpf:

<Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="2.5*" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions > <RowDefinition Height="0.3*" /> <RowDefinition Height="1.0*" /> <RowDefinition Height="2*" /> <RowDefinition Height="0.3*" /> <RowDefinition Height="0.2*" /> <RowDefinition Height="0.5*" /> <RowDefinition Height="0.5*" /> <RowDefinition Height="0.5*" /> </Grid.RowDefinitions> 

How to make it so that when hovering on a TextBlock located in row 6 (with the merging of two columns) takes up the entire red area (Row = 1, Column = 0, ColumnSpan = 2 RowSpan = 7 - i.e., only it remains). And when you hover on the zero line, everything came back. Markup

  • To use Trigger for an element, and set parameters there, it’s your grid. - NewView

1 answer 1

Something like this:

 <Grid Margin="5"> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="2.5*" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions > <RowDefinition Height="0.3*" /> <RowDefinition Height="1.0*" /> <RowDefinition Height="2*" /> <RowDefinition Height="0.3*" /> <RowDefinition Height="0.2*" /> <RowDefinition Height="0.5*" /> <RowDefinition Height="0.5*" /> <RowDefinition Height="0.5*" /> </Grid.RowDefinitions> <TextBlock Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." TextWrapping="Wrap" Grid.ColumnSpan="2"> <TextBlock.Style> <Style TargetType="TextBlock"> <Setter Property="Grid.Row" Value="6"/> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Grid.Row" Value="1"/> <Setter Property="Grid.RowSpan" Value="7"/> </Trigger> </Style.Triggers> </Style> </TextBlock.Style> </TextBlock> </Grid> 

enter image description here

If other controls will be displayed on top of your TextBlock , install Panel.ZIndex more.

  • I do not understand, I see that everything works. But it’s not enough that ZIndex 10000 doesn’t help to erase, so the rou does not change either (i.e. only the last 3 lines are used) - Sergey
  • For a tip, thank you very much, now I will try to understand what is wrong. - Sergey
  • the problem was that with texblock did not remove the property Grid. Row = 6 - Sergey
  • Note that the Grid.Row set by the setter in the style, if you specify it directly in the markup, the trigger cannot redefine it, because will have lower priority - Andrew NOP