Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin Forms Prism DialogService show behind ModalNavigation

I am using a custom DialogService, the problem I have is that I first show a page as a modal and when sending to display the DialogPage it is apparently not shown but it really is behind the model page.

Invocation of the modal page

await _navigationService.NavigateAsync("ProfilePage", useModalNavigation: true);

Xaml CustomDialog

<ContentView  xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:prism="http://prismlibrary.com"
              prism:DialogLayout.LayoutBounds="0.5, 0.5, -1, -1"
             prism:DialogLayout.RelativeWidthRequest="0.60"
              BackgroundColor="White"
             x:Class="ComedorIndustrial.Prism.Views.MessageDialog">

    <Grid Padding="30,60">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Image Source="iconoError.png" />
        <Label Text="{Binding Title}" HorizontalTextAlignment="Center" TextColor="#ee3837" Grid.Row="1" Style="{StaticResource RobotoBold}" FontSize="30"/>
        <Label Text="{Binding Message}" HorizontalTextAlignment="Center" TextColor="#bdbcc2" Grid.Row="2" FontSize="14" />
        <Button Text="Volver a intentar"
            Command="{Binding CloseCommand}"
            BackgroundColor="#ee3837" BorderRadius ="25"  TextColor="White" HorizontalOptions="FillAndExpand" Opacity="1" FontSize="12" Margin="0,15,0,0"
            Grid.Row="3"/>
    </Grid>

</ContentView>

Custom dialog invocation

   public static void ShowAlert(this IDialogService dialogService, string title, string message)
    {
                var parameters = new DialogParameters
        {
            { "title", title },
            { "message", message }
        };
        dialogService.ShowDialog("MessageDialog", parameters);
    }

EDIT:

I have solved it!

Add the plugin: Prism.Plugin.Popups

And then add the following line of code in App.xaml.cs: containerRegistry.RegisterPopupDialogService();

The documentation is on the following page: popups.prismplugins.com

Regards!

like image 928
Jose Manuel Trinidad Avatar asked Dec 02 '19 14:12

Jose Manuel Trinidad


1 Answers

What you've described is a known bug in Prism 7.2. This issue is fixed in Prism 8, or as you've noted you can simply use the Prism.Plugin.Popups to use the PopupPage variant of the service.

like image 90
Dan Siegel Avatar answered Jan 02 '23 10:01

Dan Siegel