I have this ScrollViewer, which I add elements to programically:
<ScrollViewer VerticalSnapPointsAlignment="Near"
VerticalSnapPointsType="Mandatory"
VerticalScrollMode="Enabled"
VerticalScrollBarVisibility="Hidden"
ZoomMode="Disabled"
Width="400"
Height="400"
x:Name="MainFeatureScrollViewer"
ViewChanging="ScrollViewer_ViewChanging">
<StackPanel x:Name="MainFeatureStackPanel" />
</ScrollViewer>
When I call ChangeView like below it returns false and nothing happens. Why wouldn't this be working?
bool result = this.MainFeatureScrollViewer.ChangeView(null, 400, null, true);
Just had the same problem - the base problem here was that my code did call ChangeView()
twice in the same cycle - once on a non-GUI thread (which returned true
, but of course did not really scroll to the desired position as it was not on the GUI thread), and later in a dispatcher method on the GUI thread (which returned false
, because the scrollViewer apparently saw that it already had gotten a new scroll position which it was not showing yet).
Once I removed the ChangeView()
calls that were not done on the GUI thread it worked fine. It would help if the documentation of ScrollViewer
would explain in which cases it will return false
, though ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With