Any information about the default ScrollViewer for apps with DependencyObject as a parent?

65 Views Asked by At

MainWindow.xaml.cs

using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Input;
using System.Diagnostics;

namespace TestApp3
{
    public sealed partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void TestButton_GettingFocus(UIElement sender, GettingFocusEventArgs args)
        {
            var old = args.OldFocusedElement;
            Debug.WriteLine(old?.GetType().FullName);
        }
    }
}

MainWindow.xaml

<Window
    x:Class="TestApp3.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Grid>
        <Button x:Name="_testButton"
                Content="TestButton"
                GettingFocus="TestButton_GettingFocus"/>
    </Grid>
</Window>

1

In this app, click the free space on the Grid and press the Button to Microsoft.UI.The Xaml.Controls.ScrollViewer is output and its parent is Microsoft.UI.Xaml.DependencyObject.

I've looked at the various properties of this, but I don't know where it came from. Is there any relevant information?

1

There are 1 best solutions below

2
Andrew KeepCoding On BEST ANSWER

That should be the RootScrollViewer. You can see it using the Live Visual Tree.

There's not much info about it, generally speaking you don't need to know much about it, but at least now you know where that ScrollViewer comes from.