title: Wpf Prism Region Navigation
body: <p>I've been trying to get view-based navigation to work using Prism and regions. I tried going through the documentation on MSDN, but for some reason I can't get it to work, and I don't know what I am doing wrong. So this is what I got so far:</p>
  
  <p>MainShellViewModel.cs</p>
  
  <pre><code>//Private Variables
  private readonly IRegionManager _regionManager;
  
  //Public Variables
  public DelegateCommand&lt;string&gt; NavigateCommand { get; set; }
  
  //Functions and Methods
  public MainShellViewModel(IRegionManager regionManager)
  {
      //Region Manager
      _regionManager = regionManager;
      NavigateCommand = new DelegateCommand&lt;string&gt;(Navigate);
      Initialize();
  }
  
  public void Initialize()
  {
      //Startup View
      _regionManager.RegisterViewWithRegion("ViewMainFrame", typeof(Views.Dashboard));
  }
  
  public void Navigate(string uri)
  {
      //Navigation
      if(uri != null)
      {
          _regionManager.RequestNavigate("ViewMainFrame", uri);
      }
  }
  </code></pre>
  
  <p>Side note: One of the many tutorials I followed had me put in that Navigate method, do I need it? I am using the MainShellViewModel as the Main view that is injected on startup.</p>
  
  <p>DashboardViewModel.cs: (Contains the error)</p>
  
  <pre><code>{
      //Private Variables
      private bool _canExercise = true;
  
      //Public Variables
      public bool CanExercise()
      {
          return _canExercise;
      }
  
      RelayCommand _exerciseSelCommand;
      public ICommand ExerciseSelCommand
      {
          get
          {
              if (_exerciseSelCommand == null)
                  _exerciseSelCommand = new RelayCommand(ExerciseSel, CanExercise);
  
              return _exerciseSelCommand;
          }
      }
  
      //Dashboard Functions and Methods
      IRegion _regionManager;
  
      private void ExerciseSel()
      {
          SoundPlayers.ButtonSound();
          _regionManager.RequestNavigate(new Uri("ExerciseView", UriKind.Relative)); //This gives me the error, it says it can't be nullable?
      }
  </code></pre>
  
  <p>Here is where I register my containers/views, etc.</p>
  
  <p>Bootstrapper.cs:</p>
  
  <pre><code>protected override void ConfigureContainer()
  {
      base.ConfigureContainer();
      #region Region Register Zone
      //register views here!
      Container.RegisterType(typeof(object), typeof(Views.LoginView), "LoginView");
      Container.RegisterType(typeof(object), typeof(Views.Dashboard), "Dashboard");
      Container.RegisterType(typeof(object), typeof(Views.ExerciseView), "SettingsView"); 
      Container.RegisterType(typeof(object), typeof(Views.ResultsView), "ResultsView");
      Container.RegisterType(typeof(object), typeof(Views.UserCreationView), "UserCreationView");
      #endregion
  }
  </code></pre>
  
  <p>So basically I just want to be able to get from the Dashboard (Which is my current startup view) to any other view that's registered in my containers on a click of a button.</p>
  
  <p>MainShell.xaml:</p>
  
  <pre><code>&lt;Window x:Name="Shell" 
      x:Class="Equinox.Views.MainShell"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      mc:Ignorable="d"
      xmlns:prism="http://www.codeplex.com/prism"
      prism:ViewModelLocator.AutoWireViewModel="True"
      Title="Equinox"
      FontFamily="Quicksand"
      Height="900" 
      Width="1500"
      SizeToContent="WidthAndHeight"
      ResizeMode="CanResize"
      Background="#EEF3F4"
      WindowStyle="SingleBorderWindow"
      Icon="/Equinox;component/favicon.ico"
      WindowStartupLocation="CenterScreen"&gt;
  
  &lt;!-- Main View Region --&gt;
  
  &lt;ContentControl x:Name="ContentControlMain"
                  prism:RegionManager.RegionName="ViewMainFrame" 
                  Focusable="False"/&gt;
  </code></pre>
  
  <p></p>
  
  <p>However, I keep getting errors when I try to make my region take another view. The way I was doing it was by using my DashboardViewModel, and creating another <code>IRegionManager</code> named <code>_regionManager</code>, and doing the RequestNavigation. I got no errors until I ran it and pressed the button that should link me to the next view.</p>
  
  <p>Any help would be appreciated!</p>
  
  <p>Thanks!</p>