I'm using the BladeView
control from Microsoft's Windows Community Toolkit. When the application window is < 640px, the BladeMode
property changes to Fullscreen
.
When a new blade is created in my code behind, I want the BladeView
to scroll to the right so that new blade is displayed. It seems like I should be able to use StartBringIntoView()
to accomplish this, but it's not doing anything.
Here's what I'm doing:
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);
}
This is what my XAML tree looks like:
I just needed to use bladeView.UpdateLayout()
before calling StartBringIntoView()
.
Example:
if (bladeView.BladeMode == BladeMode.Fullscreen)
{
// update the layout so StartBringIntoView() works
bladeView.UpdateLayout();
// scroll BladeView to newly-created BladeItem
newBlade.StartBringIntoView();
}