aelyo-softworks / Wice

Windows Interface Composition Engine is a .NET C# UI engine for creating Windows application.
Other
107 stars 5 forks source link

How to move scrollbar to top or buttom in ScrollView #5

Closed Charltsing closed 8 months ago

Charltsing commented 8 months ago

捕获

Why is the scrollbar located in the middle?

How to move scrollbar to top or buttom in ScrollView

smourier commented 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:

image

Charltsing commented 8 months ago

i try VerticalOffset, but it does not work 1

i try VerticalAligment, it works fine 2

i think i need a method ,maybe like ScrollTo(folat offset) ...

smourier commented 8 months ago

Wice visuals have different states during their lifetime. Most importants (in order) are:

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);
Charltsing commented 8 months ago

thanks, it works fine