If VerticalScrollbarVisibility of a Scrollviewer is set to Auto, the MeasureOverride method of that ScrollViewer, first sets the ComputedVerticalScrollbarVisibility to Collapsed. Only then, it calculates the correct value and changes it again, if necessary. The same behavior for the horizontal scrollbar.
You can see this here: https://referencesource.microsoft.com/#PresentationFramework/src/Framework/System/windows/Controls/ScrollViewer.cs,1202
We bind to the ComputedVerticalScrollbarVisibility property, triggering some margin changes. This triggers a MeasureOverride, resulting in a loop. We have other workarounds to fix this, but I'm wondering why it is coded that way.
Why is it first set to Collapsed, before setting the correct, calculated, value?