Closed Charltsing closed 8 months ago
You can use ScrollViewer.VerticalOffset (set it to 0). You can test this using the integrated (debug) tool accessible with the F9 key:
i try VerticalOffset, but it does not work
i try VerticalAligment, it works fine
i think i need a method ,maybe like ScrollTo(folat offset) ...
Wice visuals have different states during their lifetime. Most importants (in order) are:
arrange time (placed on the scene)
Some properties can be set at creation time but will be overriden by the engine when the visual is attached to composition, when it's measured, when it's arranged (placed in the scene). VerticalOffset is first computed after arrange phase.
So, something like this should work:
public override void Layout(Visual parent)
{
var sv = new ScrollViewer();
sv.Height = 200;
sv.Width = 500;
parent.Children.Add(sv);
Dock.SetDockType(sv, DockType.Top);
sv.DoWhenArranged(() => sv.VerticalOffset = 0);
thanks, it works fine
Why is the scrollbar located in the middle?
How to move scrollbar to top or buttom in ScrollView