Skip to content

[Feature]: Make GotoTop support ListView #235

Closed

Description

@hoshiizumiya

feature proposal

Make the GotoTop support the ListView. That would be great.

Additional context

Many control in the generic.xaml didn't expose their ScrollVier(er) directly in the xaml such as https://github.com/microsoft/microsoft-ui-xaml/blob/354bf6017e6443023214d34309dfdf0fe2d526b1/dxaml/xcp/dxaml/themes/generic_perf2026.xaml#L9447-L9551 , which we can't set the <Setter Property="ScrollViewer.Name" Value=""/> in the xaml too and causes a series of troubles. But we still can get the internal control by VisualTreeHelper.GetChild. So we may chage the

public virtual void CreateGotoAction(DependencyObject obj)
{
if (_scrollViewer != null)
{
_scrollViewer.ViewChanged -= ScrollViewer_ViewChanged;
}
if (_scrollView != null)
{
_scrollView.ViewChanged -= ScrollView_ViewChanged;
}
if (obj is ScrollViewer viewer && viewer != null)
{
_scrollViewer = viewer;
_scrollViewer.ViewChanged += ScrollViewer_ViewChanged;
if (Animated)
{
_gotoTopAction = () => _scrollViewer.ChangeView(null, 0, null, false);
}
else
{
_gotoTopAction = () => _scrollViewer.ChangeView(null, 0, null, true);
}
}
else if (obj is ScrollView view && view != null)
{
_scrollView = view;
_scrollView.ViewChanged += ScrollView_ViewChanged;
if (Animated)
{
_gotoTopAction = () => _scrollView?.ScrollTo(0, 0, new ScrollingScrollOptions(ScrollingAnimationMode.Auto));
}
else
{
_gotoTopAction = () => _scrollView?.ScrollTo(0, 0, new ScrollingScrollOptions(ScrollingAnimationMode.Disabled));
}
}
}
implementation to make it more general to use.

I'm waitting for your idea.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions