0

I'm trying to set vertical scrollbar in RichEditBox always visible. It seems that ScrollViewer attached properties should do the trick, but nothing happens, scrollbar still invisible.

Here is markup:

<ScrollViewer Grid.Row="2">
        <RichEditBox
                 Margin="10"
                 AcceptsReturn="True"
                 PlaceholderText="Enter comments here"
                 TextWrapping="Wrap"
                 Height="140"

                 ScrollViewer.IsVerticalRailEnabled="True"
                 ScrollViewer.VerticalScrollMode="Enabled"
                 ScrollViewer.VerticalScrollBarVisibility="Visible"/>
    </ScrollViewer>

So, why does scrollbar is not showing up and how to make it visible?

4

1 回答 1

1

您正在为 RichEditBox 模板内的滚动查看器设置属性值,但您也将 RichEditBox 与另一个 ScrollViewer 包围起来。

你有两个选择:

  1. 移除周围的滚动查看器并让 RichEditBox 模板中的那个处理它(推荐,除非您需要对滚动查看器执行特定操作)。
  2. 将属性移动到周围的 ScrollViewer。

如此处所示:

<ScrollViewer Grid.Row="2" IsVerticalRailEnabled="True" VerticalScrollMode="Enabled" VerticalScrollBarVisibility="Visible">
    <RichEditBox
             Margin="10"
             AcceptsReturn="True"
             PlaceholderText="Enter comments here"
             TextWrapping="Wrap"
             Height="140"/>
</ScrollViewer>
于 2014-12-17T17:07:56.293 回答