Prism RequestNavigate not working in a Popup window

264 views Asked by At

I am implementing Prism navigation in a Pop up window raised with InteractionRequest object. My Main View contains a TabControl region with 2 views (view A, view b). The Main View looks like this:

<Grid>
    <TabControl prism:RegionManager.RegionName="PrivateVehiclePopupRegion">
        <TabControl.ItemContainerStyle>
            <Style TargetType="{x:Type TabItem}">
                <Setter Property="Visibility" Value="Collapsed"/>
            </Style>
        </TabControl.ItemContainerStyle>
    </TabControl>          
</Grid>

View A contains a button with a command to Navigate to view B. And in the same way, view B contains a button to navigate to View A. All three views share the same view-model (which I made sure only one instance of the view-model was created).

View A and view B are registered in the Initialize method of the Module:

public void Initialize()
{
    ...
    RegionManager.RegisterViewWithRegion(RegionNames.PrivateVehiclePopupRegion, typeof(PrivateVehiclePopupReadView)); // View A
    RegionManager.RegisterViewWithRegion(RegionNames.PrivateVehiclePopupRegion, typeof(PrivateVehiclePopupEditView));  // View B    
}

When I execute the program, view A is loaded, but when the corresponding button is pressed to navigate to the other view, the NavigateToViewB() method is reached successfully, but when the RequestNavigate is called, nothing happens. I also tried to invert the order in which views are registered, so View B is registered first, and the View B is loaded, but the RequestNavigate to A doesn't work.

I added a callback method to investigate the issue, like this:

private void NavigateToEdit()
{
    this.regionManager.RequestNavigate(RegionNames.PrivateVehiclePopupRegion, EditUri,
        (NavigationResult nr) =>
        {
            var error = nr.Error;
            var result = nr.Result;
            // put a breakpoint here and checkout what NavigationResult contains
        });
}

Howerver, Error is null and Result is false... which tells nothing. Any ideas? I've done navigation before and it works fine, but this is the first time I implement navigation on a Popup window.

0

There are 0 answers