[英]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.