[英]Displaying Border on TextBlock when TextBlock placed inside ScrollViewer
我有WPF应用程序,在我的WPF表单之一中有TextBlock。 我将TextBlock放在ScrollViewer中以提供滚动功能。 我想要在TextBlock上使用边框,因此,我在XAML
编写了以下代码。
<ScrollViewer Margin="230,32,12,147">
<Border BorderThickness="1" BorderBrush="Black">
<TextBlock Name="textBlock1"></TextBlock>
</Border>
</ScrollViewer>
滚动条GUI如下所示。
底部边框显示向下滚动到TextBlock。 用户体验不适用于此设计。 因此,我尝试使用以下代码,但没有显示边框。
<Border BorderThickness="1" BorderBrush="Black">
<ScrollViewer Margin="230,32,12,147">
<TextBlock Name="textBlock1"></TextBlock>
</ScrollViewer>
</Border>
将TextBlock放入ScrollViewer时如何显示边框?
在ScrollViewer控件中设置边框!
<ScrollViewer Margin="230,32,12,147" BorderThickness="5">
<TextBlock Name="textBlock1"></TextBlock>
</ScrollViewer>
在属性窗口中,展开“ 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>
外边界代码示例:
<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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.