title: I need to navigate to another view contains child objects of parent object in WPF with MVVM
body: <p>I working on WPF project and trying to not break MVVM concepts with zero code in Views.</p>
  
  <p>In conclusion i have a grid lists a list of job object properties and i want when i click on show logs button inside every grid row it shows to me another grid which contains logs for this job without breaking MVVM concept.</p>
  
  <p>I only want to show another grid contains a child property which is a list of objects, it's straightforward easy thing in all other techniques MVC, MVP but here in MVVM it's some sort of strange, i searched for that for about 20 questions and no straightforward solution </p>
  
  <p><a href="https://i.stack.imgur.com/2jdTq.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2jdTq.jpg" alt="enter image description here"></a></p>
  
  <p>Details:
  I have a MainView.xaml (Window), JobsView.xaml (UserControl), LogsView.xaml(UserControl) and i have corresponding ViewModel for each one.</p>
  
  <p>Job class contains id, status, ... and a list of Log object:</p>
  
  <pre><code> public class Job
  {
      public Job()
      {
          Logs = new List&lt;Log&gt;();
      }
      [Key]
      public Guid JobID { get; set; }
      public JobStatus Status { get; set; }
      public virtual ICollection&lt;Log&gt; Logs { get; set; }
  }
  </code></pre>
  
  <p>I shown a JobsView.xaml (UserControl) in the MainView.xaml to list all job objects properties and i created a custom button for each job to shown logs.</p>
  
  <pre><code>&lt;Controls:MetroWindow ...&gt;
  &lt;Grid&gt;
      &lt;DockPanel&gt;
               &lt;my:JobView /&gt;
      &lt;/DockPanel&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>JobView.xaml markup:</p>
  
  <pre><code>&lt;UserControl x:Class=...&gt;
  &lt;Grid&gt;
      &lt;DataGrid x:Name="jobsDataGrid"
                ItemsSource="{Binding Jobs}"
                SelectedItem="{Binding selectedJob}"
                AutoGenerateColumns="False"
                EnableRowVirtualization="True"
                RowDetailsVisibilityMode="VisibleWhenSelected"
                IsReadOnly="True"&gt;
                  &lt;DataGrid.Columns&gt;
              &lt;DataGridTextColumn x:Name="jobIdColumn"
                                  Binding="{Binding JobID}"
                                  Header="Job Id"
                                 Width="SizeToHeader"
                                  /&gt;
  
              &lt;DataGridTemplateColumn&gt;
                          &lt;DataGridTemplateColumn.CellTemplate&gt;
                              &lt;DataTemplate&gt;
                                  &lt;Button Content="Show Logs"
                                          Command="{Binding ShowLogsCommand}"
                                          /&gt;
                              &lt;/DataTemplate&gt;
                          &lt;/DataGridTemplateColumn.CellTemplate&gt;
                      &lt;/DataGridTemplateColumn&gt;
                  &lt;/DataGrid.Columns&gt;
              &lt;/DataGrid&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>I want when any body click on Show Logs button it shown LogsView.xaml user control inside MainView.xaml instead of JobsView.</p>
  
  <p>In LogViewModel i have a contructor to take jobId and return the logs:</p>
  
  <pre><code>    public class LogViewModel : BindableBase // INotifyPropertyChanged
  {
      private Log log = new Log();
      private UnitOfWork unitOfWork = new UnitOfWork();
  
      public LogViewModel()
      {
          if (DesignerProperties.GetIsInDesignMode(new System.Windows.DependencyObject())) return;
          Logs = new ObservableCollection&lt;Log&gt;(unitOfWork.Logs.Get(null, ls =&gt; ls.OrderBy(l =&gt; l.LogID)).ToList());
      }
  
      public LogViewModel(Guid jobId)
      {
          if (DesignerProperties.GetIsInDesignMode(new System.Windows.DependencyObject())) return;
          Logs = new ObservableCollection&lt;Log&gt;(unitOfWork.Logs.Get(l =&gt; l.JobID == jobId, ls =&gt; ls.OrderBy(l =&gt; l.LogID)).ToList());
      }
  
  
      public ObservableCollection&lt;Log&gt; Logs { get; set; }
  
  
    //  public event PropertyChangedEventHandler PropertyChanged;
  
  
  }
  </code></pre>
  
  <p>But now i trying to make a navigation service and tries some techniques but it didn't works.</p>