Is there a reason I cannot navigate to a new page from a popup?

iooovoltsiooovolts Member ✭✭
edited September 10 in Xamarin.Forms

I am using Rg.plugins.Popup for popups in my Xamarin.Forms application and even though I have registered my View for navigation , when I try to navigate from my popup view to a new page, it just closes and popup and nothing happens. Does anyone have a workaround to this please? Thanks!

Popup View

<popup:PopupPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:popup="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup"
             xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
             prism:ViewModelLocator.AutowireViewModel="True" 
             mc:Ignorable="d"
             Visual="Material"
             x:Class="Test.Views.ProfileOptionsView">
    <ScrollView HorizontalOptions="Center"
                VerticalOptions="Center">
        <Frame Margin="15"
               HorizontalOptions="Center"
               BackgroundColor="White">
            <StackLayout IsClippedToBounds="True"
                         Padding="10, 5"
                         Spacing="3">
                <Button Text="Edit profile"
                        Command="{Binding NavigateToEditProfileViewCommand}"/>
            </StackLayout>
        </Frame>
    </ScrollView>
</popup:PopupPage>

PopUp ViewModel

public class ProfileOptionsViewModel : BaseViewModel
{
    private INavigationService _navigationService;
    public DelegateCommand NavigateToEditProfileViewCommand { get; }
    public ProfileOptionsViewModel(INavigationService navigationService)
    {
        _navigationService = navigationService;
        NavigateToEditProfileViewCommand = new DelegateCommand(async () => await _navigationService.NavigateAsync("EditProfileView"));
    }
}

Answers

  • ColeXColeX Member, Xamarin Team Xamurai
    edited September 10

    I guess you click on the background of the page but not the button , so popupPage closes and nothing happens.

    Add breakPoints on method OnBackgroundClicked in popupPage and the command NavigateToEditProfileViewCommand to see which one is invoked .

  • iooovoltsiooovolts Member ✭✭

    @ColeX the button is big and black thanks to Material Visual, I definitely click on the button, and when I set breakpoints it hit my NavigateToEditProfileViewCommand and executes the NavigateAsync code but then nothing happens. Unless I am misunderstanding what you are saying? Thanks.

  • ColeXColeX Member, Xamarin Team Xamurai
    edited September 12

    Try Prism.Plugin.Popups .

    It provides an extremely lightweight framework for implementing Popup Pages using the Rg.Plugin.Popup package with Prism.Forms and provides extensibility for Prism.Forms INavigationService to handle Popup Views.

  • iooovoltsiooovolts Member ✭✭

    Hi @ColeX , that is in fact the package I am using :smile: ! If you have a working project where you can navigate to a whole content page from a popup view that would be most helpful. Maybe I would be able to spot some differences, thanks a lot.

Sign In or Register to comment.