Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

regionmanager.requestnavigate not working

$
0
0

Hi,

Using MVVM with Prism I have a little problem.

Executing the LoadContentCommandExecute() form the view navigation works fine.

Executing the LoadContentCommandExecute() as a reaction to a event the code is executed without errors, but the desired view is not loaded...

What is it I am doing wrong?

Thanks for hints and help!

Regards
Rainer

public class StatusContextViewModel : ViewModelBase, IStatusContextViewModel
{
    private static Logger logger = LogManager.GetCurrentClassLogger();
    private IRegionManager regionManager;
    private IEventAggregator eventAggregator;

    public StatusContextViewModel()
    {
        // designtime only
    }

    public StatusContextViewModel(IUnityContainer container)
    {
        this.regionManager = container.Resolve<IRegionManager>();
        this.eventAggregator = container.Resolve<IEventAggregator>();
        this.LoadContentCommand = new DelegateCommand(this.LoadContentCommandExecute);
        this.SubscribeToEvents();
    }

    private void SubscribeToEvents()
    {
        this.eventAggregator.GetEvent<TestBenchAbortionEvent>().Subscribe(s => this.LoadContentCommandExecute());
    }

    public DelegateCommand LoadContentCommand { get; set; }
        
    private void LoadContentCommandExecute()
    {
        try
        {
            this.regionManager.RequestNavigate(RegionNames.LoadSpectrumTestContentRegion, typeof(StatusContentView).FullName);
            logger.Info("User Action : Status View selected");
        }
        catch (Exception exception)
        {
            logger.Error(exception.FullMessage);
            throw;
        }
    }
}



Viewing all articles
Browse latest Browse all 18858

Trending Articles