Jviaches
Jviaches

Reputation: 843

Put TextBlock on top of another TextBlock

I tried to implement case in which one TextBlock appears on top of another TextBlock, playing with Visibility property - but it doesn't working yet.

TextBlock are inside DockPanel:

<DockPanel Grid.Row="1" Margin="5">
    <TextBlock Text="Text1" Height="20" HorizontalAlignment="Right" DockPanel.Dock="Right">
        <TextBlock Text="Text2" Background="Aqua" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Visibility="{Binding IfDeviceSelected, NotifyOnSourceUpdated=True, Converter={StaticResource  ResourceKey=BoolToVisibilityConverter}}" />
    </TextBlock>

    <TextBlock Text="@Device Focus:" Height="20" HorizontalAlignment="Right" DockPanel.Dock="Right" />
</DockPanel>

Upvotes: 1

Views: 1363

Answers (1)

sa_ddam213
sa_ddam213

Reputation: 43596

You will want to use a Grid to group these TextBlocks, DockPanel/StackPanel will not allow overlapping controls(without horrible manipulation of Margins etc)

  <DockPanel Grid.Row="1" Margin="5" >
     <Grid DockPanel.Dock="Right" >
         <TextBlock Text="Text1" />
         <TextBlock Text="Text2" Background="Aqua" Visibility="{Binding IfDeviceSelected, NotifyOnSourceUpdated=True, Converter={StaticResource  ResourceKey=BoolToVisibilityConverter}}" />
     </Grid>
     <TextBlock Text="@Device Focus:" Height="20" HorizontalAlignment="Right" DockPanel.Dock="Right" />
  </DockPanel>

Upvotes: 2

Related Questions