Can the ScrollOrientation of a ScrollView be changed afer the ScrollView is displayed?

Blaise 41 Reputation points

I have a Xamarin Editor view in a ScrollView. The Editor has AutoSize set to TextChanges. The ScrollView is defined in XAML like so:

            Orientation="{Binding ScrollViewOrientation}" 

In the ctor of page's view model, I set the ScrollViewOrientation property like so:

    if (_ut.Prefs.InfoTextWordWrap)
        ScrollViewOrientation = ScrollOrientation.Vertical;
        ScrollViewOrientation = ScrollOrientation.Both;

And the ScrollViewOrientation property is defined in the view model like so:

    public ScrollOrientation ScrollViewOrientation
            return _scrollOrient;
            if (_scrollOrient != value)
                _scrollOrient = value;

The WordWrap property in the view model is defined like so:

public bool WordWrap
    get { return _wordWrap; }
        if (value != _wordWrap)
            _wordWrap = value;
            _ut.Prefs.InfoTextWordWrap = value;
            ScrollViewOrientation = _wordWrap ? ScrollOrientation.Vertical : ScrollOrientation.Both;
            if (_loaded)


This works as intended: with word wrap on, I get vertical scrolling only and the text in the Editor wraps; with word wrap off, I get both vertical and horizontal scrolling and the text in the Editor does not wrap.

The word wrap property for the Android app is set on an options page. I got the "bright" idea of putting a Word Wrap checkbox on the page with the ScrollView/Editor so the user could toggle word wrap while viewing the text, instead of having to back out of the page, go to the options page, change word wrap, close the options page and then reload the text page.

But having made the changes, tapping the word wrap checkbox has no effect. For example, if I load this page with word wrap turned OFF, I get no wrapping and scrolling in both directions (as desired). Tapping the word wrap checkbox does nothing to the UI (other than display the check). But if I leave the page and then come back to it, wrap is now ON yielding only vertical scrolling and text wrapping.

That is, the word wrap preference was changed (and persisted), but it would seem that changing the ScrollOrientation of the ScrollView after it has been displayed has no effect.

I could certainly be wrong ... any feedback would be appreciated.

VS 2019, c# on Win 10
Xamarin Forms v4.8.0.1560
Yes, the Xamarin Forms version is "old" (but "only" 4 months old). I'd like to understand what the issue is before updating

A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,210 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 58,741 Reputation points Microsoft Vendor


    Welcome to our Microsoft Q&A platform!

    Can the ScrollOrientation of a ScrollView be changed afer the ScrollView is displayed?

    Based on my test, this answer is No, I make a vertical ScrollView, then use a button to change the ScrollOrientation.Vertical to ScrollOrientation.Horizontal, but it not work, MVVM is the same with set my way, so it cannot be changed afer the ScrollView is displayed.

    Best Regards,

    Leon Lu

    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.