I am trying to learn Prism navigation support. I currently have a prism region and I want to load a view into this region using RegionManager.RequestNavigate (). Navigation occurs, however, IsNavigationTarget () from INavigationAware is not called even if the ViewModel implements the INavigationAware interface in the navigation view. Here is the code I'm using.
Shell:
<StackPanel Margin="10"> <TextBlock Text="Main Window"/> <Button Content="RegionA" Command="{Binding NavigateToACommand}" /> <ContentControl prism:RegionManager.RegionName="MainRegion"/> </StackPanel>
ShellViewModel:
private void NavigateToA () { Uri uri = new Uri("RegionAView", UriKind.Relative); RegionManager.RequestNavigate("MainRegion", uri); }
RegionAView:
<UserControl x:Class="NavigationExample.RegionAView" <Grid> <TextBlock Text="This is Region A"/> </Grid> </UserControl>
RegionAViewModel
public class RegionAViewModel : INavigationAware{ public RegionAViewModel() { } public bool IsNavigationTarget(NavigationContext navigationContext) { return false;
RegionAView.xaml.cs
[Export("RegionAView")] public partial class RegionAView : UserControl { public RegionAView() { InitializeComponent(); } }
Why isnavigationTarget () not starting until navigation is complete?
source share