1

我试图实现一个TextBlock出现在另一个之上的情况TextBlock,玩Visibility财产 - 但它还没有工作。

TextBlock在里面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>
4

1 回答 1

2

您将希望使用 aGrid对这些进行分组TextBlocksDockPanel/StackPanel不允许重叠控件(没有可怕的边距操作等)

  <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>
于 2013-04-08T00:38:37.820 回答