UWP XAML BladeView 控件 - 将 newly-created BladeItem 滚动到视图中

UWP XAML BladeView control - scroll newly-created BladeItem into view

我正在使用 Microsoft Windows 社区工具包中的 BladeView 控件。当应用程序 window < 640px 时,BladeMode 属性 变为 Fullscreen.

当在我后面的代码中创建一个新的 blade 时,我希望 BladeView 向右滚动以便显示新的 blade。 似乎 我应该能够使用 StartBringIntoView() 来完成此操作,但它什么也没做。

这是我正在做的事情:

if (bladeView.BladeMode == BladeMode.Fullscreen)
{
    // current window width
    Rect windowBounds = Window.Current.Bounds;
    int currentWidth = (int)windowBounds.Width;

    // scroll to view
    BringIntoViewOptions opts = new BringIntoViewOptions();
    Rect target = new Rect { Height = windowBounds.Height, Width = windowBounds.Width, X = currentWidth, Y = 0 };
    opts.TargetRect = target;
    newBlade.StartBringIntoView(opts);
}

这是我的 XAML 树的样子:

我只需要在调用 StartBringIntoView() 之前使用 bladeView.UpdateLayout()

示例:

if (bladeView.BladeMode == BladeMode.Fullscreen)
{
    // update the layout so StartBringIntoView() works
    bladeView.UpdateLayout();

    // scroll BladeView to newly-created BladeItem
    newBlade.StartBringIntoView();
}