【问题标题】:Silverlight 2.0 - scroll vertically, wrap horizontallySilverlight 2.0 - 垂直滚动,水平环绕
【发布时间】:2008-12-01 12:42:14
【问题描述】:

在 Silverlight 2.0 中。我有一些内容要垂直滚动并水平换行。在控件中,我有一个停靠面板。填充它的 DockPanel 的最后一个子元素是 ScrollViewer

<UserControl x:Class="MyProject.MyControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:WinControls="clr-namespace:Microsoft.Windows.Controls;
      assembly=Microsoft.Windows.Controls" 
    Width="400" Height="300">
    <WinControls:DockPanel LastChildFill="True">
    ...
<ScrollViewer x:Name="MessageScroll" HorizontalScrollBarVisibility="Hidden"
     VerticalScrollBarVisibility="Auto" BorderThickness="0" >
    <Controls:TextDisplay x:Name="TextDisplay"></Controls:TextDisplay>
</ScrollViewer>

TextDisplay 控件 XAML 如下所示:

<UserControl x:Class="MyProject.TextDisplay"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
        <TextBlock x:Name="TextDisplayText" TextWrapping="Wrap">
        </TextBlock>
</UserControl>

我想要发生的事情:TextDisplay 应该占据控件的主要区域, 如果高度不合适,则带有垂直滚动条。消息在水平方向过长时应该换行。

滚动有效,但现在消息不会在右侧边缘换行。他们只是切断了。它不限制宽度,只是隐藏 Horizo​​ntalScrollBar。如果我设置 Horizo​​ntalScrollBarVisibility="Auto" 我可以看到它们向右滚动。我如何强制它换行?

【问题讨论】:

    标签: silverlight xaml silverlight-2.0 scroll word-wrap


    【解决方案1】:

    尝试将 ScrollViewer 的 Horizo​​ntalScrollBarVisibility 设置为 Disabled(或不指定值,因为 Disabled 是默认值),然后 TextDisplay 将正确换行,并且不会显示水平滚动条。

    【讨论】:

      猜你喜欢
      • 2012-02-25
      • 2014-03-16
      • 1970-01-01
      • 2021-11-13
      • 2014-01-09
      • 1970-01-01
      • 2018-02-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多