Anthony
Anthony

Reputation: 2824

Show scrollbar in RichEditBox

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?

Upvotes: 0

Views: 401

Answers (1)

Murven
Murven

Reputation: 2387

You are setting the property values for the scroll viewer that lives inside the RichEditBox Template, but you are also surrounding the RichEditBox with another ScrollViewer.

You have two options:

  1. Remove the surrounding scroll viewer and let the one in the RichEditBox template handle it (recommended unless you need to do something specific with your scroll viewer).
  2. Move the properties to the surrounding ScrollViewer.

As shown here:

<ScrollViewer Grid.Row="2" IsVerticalRailEnabled="True" VerticalScrollMode="Enabled" VerticalScrollBarVisibility="Visible">
    <RichEditBox
             Margin="10"
             AcceptsReturn="True"
             PlaceholderText="Enter comments here"
             TextWrapping="Wrap"
             Height="140"/>
</ScrollViewer>

Upvotes: 1

Related Questions