当TextBlock放在ScrollViewer中时,在TextBlock上显示边框

Jig*_*ker 0 c# wpf user-interface

我有WPF应用程序,在我的一个WPF表单中有TextBlock.我将TextBlock放在ScrollViewer中以提供滚动功能.我想在TextBlock上使用Border,所以我已经编写了以下代码XAML.

<ScrollViewer Margin="230,32,12,147">
    <Border BorderThickness="1" BorderBrush="Black">
          <TextBlock Name="textBlock1"></TextBlock>
      </Border>
 </ScrollViewer>
Run Code Online (Sandbox Code Playgroud)

使用scrollBar GUI显示如下.

在此输入图像描述

向下滚动到TextBlock时显示底部边框.用户体验不适合这种设计.所以,我尝试使用下面的代码但边框没有显示.

<Border BorderThickness="1" BorderBrush="Black">
    <ScrollViewer Margin="230,32,12,147">
          <TextBlock Name="textBlock1"></TextBlock>
     </ScrollViewer>
 </Border>
Run Code Online (Sandbox Code Playgroud)

当TextBlock放在ScrollViewer中时,如何显示边框?

ope*_*wix 5

在ScrollViewer控件中设置边框!

<ScrollViewer Margin="230,32,12,147" BorderThickness="5">
      <TextBlock Name="textBlock1"></TextBlock>
 </ScrollViewer>
Run Code Online (Sandbox Code Playgroud)

在属性窗口中,展开Other组并设置BorderThickness

下一个代码效果很好:

<ScrollViewer Height="116"  Margin="115,112,0,0" Width="269">
        <Border BorderBrush="Silver" BorderThickness="5" Height="100" Width="200">
            <TextBlock Height="69" Name="textBlock1" Text="TextBlock" />
        </Border>
    </ScrollViewer>
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

外部边界的代码示例:

<Border BorderBrush="Silver" BorderThickness="5" Height="100" HorizontalAlignment="Left" Margin="167,104,0,0" Name="border1" VerticalAlignment="Top" Width="200">
        <ScrollViewer Height="83" Name="sv" Width="184">
            <TextBlock Name="textBlock1" Text="TextBlock TextBlockTextBlockTextBlock TextBlock TextBlock TextBlock TextBlock TextBlockTextBlockTextBlock TextBlock TextBlock TextBloc TextBlock TextBlockTextBlockTextBlock TextBlock TextBlock TextBloc TextBlock TextBlockTextBlockTextBlock TextBlock TextBlock TextBloc" TextWrapping="Wrap" />
        </ScrollViewer>
    </Border>
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述