WinUI3 issues with Frame loading and returning

春辉 马 0 Reputation points
2023-01-16T12:31:30.3+00:00

I'm having a magical issue with Frame, it's random. My basic code is as follows

But when I load, 99% of the time it loads successfully, and when I return, there is a high probability that there will be no content

First use ItemsRepeater to load the list, its ItemTemplate inside a custom control, and the custom control contains a Frame

<ItemsRepeaterScrollHost HorizontalAlignment="Center">

                <ScrollViewer IsVerticalScrollChainingEnabled="False">
                    <ItemsRepeater
                        x:Name="StaggeredRepeater"
                        ItemTemplate="{StaticResource StaggeredTemplate}"
                        ItemsSource="{Binding Widgets}">
                        <ItemsRepeater.Layout>
                            <common:StaggeredLayout
                                Padding="0,8,0,0"
                                HorizontalAlignment="Center"
                                ColumnSpacing="8"
                                DesiredColumnWidth="300"
                                RowSpacing="8" />
                        </ItemsRepeater.Layout>
                    </ItemsRepeater>
                </ScrollViewer>
            </ItemsRepeaterScrollHost>

Below are the loading Page code

        private void ContentFrame_Loading(FrameworkElement sender, object args)
        {
            NavigateHelper.AddFrame(Id, this.ContentFrame,AddFrameType.Replace);
            ContentFrame.Navigate(this.WidgetContent, WidgetSize, new DrillInNavigationTransitionInfo());
        }


Below are the codes that return Page

           var frame = NavigateHelper.GetFrame(WidgetId);
            if (frame!=null&&frame.CanGoBack)
            {
                frame.GoBack();
            }

Windows App SDK
Windows App SDK
A set of Microsoft open-source libraries, frameworks, components, and tools to be used in apps to access Windows platform functionality on many versions of Windows. Previously known as Project Reunion.
438 questions
{count} votes