Uwp ScrollViewer来自哪里?

Uwp ScrollViewer来自哪里?,uwp,c++-winrt,Uwp,C++ Winrt,有一个简单的页面(MainPage.xaml) 页面类如下所示 000 Button::LosingFocus Windows.UI.Xaml.Controls.Button Windows.UI.Xaml.Controls.ScrollViewer = Windows.UI.Xaml.Controls.ScrollViewer struct主页面:第页 { 内联静态单元32_t SEQ=0; 空转储(框架元素fwk) { printf(“=%ws\n”,获取类名称(fwk.data(

有一个简单的页面(MainPage.xaml)


页面类如下所示

000 Button::LosingFocus
  Windows.UI.Xaml.Controls.Button Windows.UI.Xaml.Controls.ScrollViewer
= Windows.UI.Xaml.Controls.ScrollViewer
struct主页面:第页
{
内联静态单元32_t SEQ=0;
空转储(框架元素fwk)
{
printf(“=%ws\n”,获取类名称(fwk.data());
if(fwk.Parent())
转储(fwk.Parent().as());
}  
主页()
{
尝试
{
Application::LoadComponent(*此,Uri(L“ms-appx:///MainPage.xaml"));      
FindName(L“Button”).as().LosingFocus([&](IInspectable sender,LosingFocusEventArgs const&args){
printf(“%03d按钮::失去焦点\n”,SEQ++);
if(args.NewFocusedElement())
{
printf(“%ws%ws\n”,
获取类名称(args.OldFocusedElement()).data(),
获取类名称(args.NewFocusedElement()).data();
转储(args.NewFocusedElement().as());
}
else if(args.OldFocusedElement())
printf(“%ws null\n”,
获取类名称(args.OldFocusedElement()).data();
其他的
printf(“null\n”);
});
}
捕获(hresult_错误e)
{
printf(“主页0x%x%ws\n”、int32_t(e.code()、e.message().data());
}
}
hs字符串GetRuntimeClassName()常量重写
{
返回L“主页”;
}
};
当按钮失去焦点时,输出如下

000 Button::LosingFocus
  Windows.UI.Xaml.Controls.Button Windows.UI.Xaml.Controls.ScrollViewer
= Windows.UI.Xaml.Controls.ScrollViewer
似乎UWP正试图重新聚焦于ScrollViewer,而我却找不到它。是合成的吗?非常感谢

ScrollViewer来自哪里

在测试过程中,只有在其他控件上才能聚焦时才会发生这种情况,
ScrollViewer
应该是用于渲染控件的可视容器,并且您可以从
ScrollViewer
中找到带有可视树帮助器的按钮。您可以使用以下代码来查找
按钮
是ScrollViewer的根父级

public static DependencyObject FindParent(DependencyObject dp)
{
    DependencyObject parent = null;
    DependencyObject currParent;
    currParent = VisualTreeHelper.GetParent(dp);

    do
    {
        parent = currParent;
        // find the next parent
        currParent = VisualTreeHelper.GetParent(currParent);

    } while (currParent != null);

    return (parent);
}
用法