unoplatform / uno

Build Mobile, Desktop and WebAssembly apps with C# and XAML. Today. Open source and professionally supported.
https://platform.uno
Apache License 2.0
8.76k stars 706 forks source link

[WASM] Add support for `ListViewBase.ScrollIntoView` #4772

Open xperiandri opened 3 years ago

xperiandri commented 3 years ago

Current behavior

If ListView has items enough to scroll, it is scrolled to the very bottom and the last item is selected. Then if ListView size makes vertically smaller then the last item is not kept in the view.

Expected behavior

The selected item is always kept in view. The same as it happens in UWP

How to reproduce it (as minimally and precisely as possible)

Create ListView. Set ItemsPannel as follows:

<ItemsPanelTemplate>
  <ItemsStackPanel VerticalAlignment="Bottom" ItemsUpdatingScrollMode="KeepLastItemInView" />
</ItemsPanelTemplate>

Add items to it. Select the last item. Make window smaller so that it cannot display all the items.

Workaround

Not found

Environment

Nuget Package:

Nuget Package Version(s):

<PackageReference Include="Uno.SourceGenerationTasks" Version="3.0.0-dev.21" />
<PackageReference Include="Uno.UI.WebAssembly" Version="3.3.0" />
<PackageReference Include="Uno.UI.RemoteControl" Version="3.3.0" Condition="'$(Configuration)'=='Debug'" />
<PackageReference Include="Uno.Wasm.Bootstrap" Version="2.0.0-dev.125" />
<PackageReference Include="Uno.Wasm.Bootstrap.DevServer" Version="2.0.0-dev.125" />

Affected platform(s):

IDE:

Relevant plugins:

Anything else we need to know?

jeromelaban commented 3 years ago

Thanks for the report.

It is not yet implemented: https://github.com/unoplatform/uno/blob/74b6e9fa21c94fb077c475026dd235491cdd80bd/src/Uno.UI/Generated/3.0.0.0/Windows.UI.Xaml.Controls/ListViewBase.cs#L327-L331

Neither is: https://github.com/unoplatform/uno/blob/17605edbfab824283f3051bb39943ef7b18f3f00/src/Uno.UI/UI/Xaml/UIElement.cs#L576

jasonxz commented 3 years ago

Will this mean that ListViewPersistenceHelper.SetRelativeScrollPositionAsync will be supported?

davidjohnoliver commented 3 years ago

In fact this property specifically isn't implemented (for any platform): https://github.com/unoplatform/uno/blob/a1787131bbdaf0a0c97ce57860b1f28a607d5c26/src/Uno.UI/Generated/3.0.0.0/Windows.UI.Xaml.Controls/ItemsStackPanel.cs#L12-L23

Will this mean that ListViewPersistenceHelper.SetRelativeScrollPositionAsync will be supported?

@jasonxz That seems to be a different feature, please create a new issue for it if you'd like to see it implemented.

hig-dev commented 3 years ago

I am working on a macOS project using UNO platform and ListViewBase.ScrollIntoView is unfortunately also not implemented.