I have a Xamarin Editor view in a ScrollView. The Editor has AutoSize set to TextChanges. The ScrollView is defined in XAML like so:
<ScrollView
Orientation="{Binding ScrollViewOrientation}"
VerticalScrollBarVisibility="Always"
Padding="0"
Margin="0"
>
In the ctor of page's view model, I set the ScrollViewOrientation property like so:
if (_ut.Prefs.InfoTextWordWrap)
ScrollViewOrientation = ScrollOrientation.Vertical;
else
ScrollViewOrientation = ScrollOrientation.Both;
And the ScrollViewOrientation property is defined in the view model like so:
public ScrollOrientation ScrollViewOrientation
{
get
{
return _scrollOrient;
}
set
{
if (_scrollOrient != value)
{
_scrollOrient = value;
OnPropertyChanged(nameof(ScrollViewOrientation));
}
}
}
The WordWrap property in the view model is defined like so:
public bool WordWrap
{
get { return _wordWrap; }
set
{
if (value != _wordWrap)
{
_wordWrap = value;
_ut.Prefs.InfoTextWordWrap = value;
OnPropertyChanged(nameof(WordWrap));
ScrollViewOrientation = _wordWrap ? ScrollOrientation.Vertical : ScrollOrientation.Both;
if (_loaded)
_ut.Prefs.SaveAppPrefs(Utils.SavePrefDetail.TextWrap);
}
}
}
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.
Environment:
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