Page content refreshing before navigating in Xamarin Forms with Prism

Viewed 187

During my navigation with "Hamburger menu" in Prism.Forms (Master Detail Page), my currently selected page I navigate from acts weirdly like it is refreshed/reseted. In this specific page I have "boolen rendering" in XAML where I play with IsVisible property. There is scenario where I should see only some PNG covering content beneath, but when I navigate with Hamburger, PNG disappears and I can see the content I shouldn't for a moment. It looks like property bindings are off or something. CollectionViews underneath PNG are empty, everything looks like in Visual Studio Xaml Preview during coding where XAML has no idea about bindings, it just shows everything with default content.

The XAML of this Page (MainPage.xaml) looks like this:

<Grid>

        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        
            <Image Source="nfc.png" IsVisible="{Binding IsFirstRead}" BackgroundColor="White" />
            <Button Grid.Row="1" Text="NotFirstRead" Command="{Binding NotFirstReadCommand}" />

            <Grid IsEnabled="{Binding IsFirstRead, Converter={StaticResource InverseBoolean}}" 
                            Opacity="{Binding IsFirstRead, Converter={StaticResource InverseBoolToDigit}}" 
                            HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand">

                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>

                <Button Grid.Row="0" Text="{Static resources:Strings.Button_WriteTag}" Command="{Binding WriteTagCommand}" />
                <Button Grid.Row="1" Text="FirstRead" Command="{Binding FirstReadCommand}" />

                <CollectionView Grid.Row="2" ItemsSource="{Binding FrontControlsCollection}" BackgroundColor="Yellow">
                    <CollectionView.ItemTemplate>
                        <DataTemplate>
                            <StackLayout Orientation="Vertical" >
                                <Label Text="{Binding MemoryMapItem.Name}" />
                                <Entry Text="{Binding NewValue}" Margin="0" BackgroundColor="AliceBlue">
                                    <Entry.Triggers>
                                        <DataTrigger TargetType="Entry" Binding="{Binding MemoryMapItem.DataType}" Value="{Static dt:DataType.Int}">
                                            <Setter Property="Keyboard" Value="Numeric" />
                                        </DataTrigger>
                                    </Entry.Triggers>
                                </Entry>
                            </StackLayout>
                        </DataTemplate>
                    </CollectionView.ItemTemplate>
                </CollectionView>

                <CollectionView Grid.Row="3" ItemsSource="{Binding MifarePagesCollection}" BackgroundColor="Red">
                    <CollectionView.ItemTemplate>
                        <DataTemplate>
                            <Label Text="{Binding RecordView}" />
                        </DataTemplate>
                    </CollectionView.ItemTemplate>
                </CollectionView>

            </Grid>
    </Grid>

XAML of the root (MDP):

    <MasterDetailPage.Master>
        <ContentPage Title="Menu">
            <StackLayout Padding="20">
                <Button Text="{Static resources:Strings.Label_Home }" Command="{Binding NavigateCommand}" CommandParameter="NavigationPage/MainPage" />
                <Button Text="{Static resources:Strings.Label_Language}" Command="{Binding NavigateCommand}" CommandParameter="NavigationPage/LanguagePage" />
            </StackLayout>
        </ContentPage>
    </MasterDetailPage.Master>

Root VM:

    public class RootPageViewModel : ViewModelBase
    {
        private DelegateCommand<string> _navigateCommand;

        public DelegateCommand<string> NavigateCommand => _navigateCommand ??= new DelegateCommand<string>(ExecuteNavigateCommand);

        private async void ExecuteNavigateCommand(string uri)
        {
            await NavigationService.NavigateAsync(uri);
        }

        public RootPageViewModel(INavigationService navigationService) : base(navigationService)
        {
            
        }
    }

Here is the video showing the problem: https://drive.google.com/file/d/1Z5htYQrznG86C67AmBJ8hCl9_x_FzN88/view?usp=sharing

You can even see here that PNG does not really disappear but more like its z-index is lower than everything's else (you can see it between elements).

0 Answers
Related