title: Bind MasterDetailPage from ViewModel in Xamarin Forms
body: <p>I'm trying to bind my masterdetailpage detail from viewmodel. But it doesn't work.</p>
  
  <p>Here's my code in view:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
           xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
           xmlns:local="clr-namespace:MasterDetailsSamp1"
           x:Class="MasterDetailsSamp1.MainPage"
           xmlns:vm="clr-namespace:MasterDetailsSamp1.ViewModels"&gt;
  &lt;MasterDetailPage.BindingContext&gt;
      &lt;vm:MasterDetailsViewModel/&gt;
  &lt;/MasterDetailPage.BindingContext&gt;
  
  &lt;MasterDetailPage.Master&gt;
      &lt;ContentPage Title="Menu"&gt;
          &lt;StackLayout&gt;
  
          &lt;/StackLayout&gt;
      &lt;/ContentPage&gt;
  &lt;/MasterDetailPage.Master&gt;
  
  &lt;MasterDetailPage.Detail&gt;
      &lt;NavigationPage&gt;
  
      &lt;/NavigationPage&gt;
  &lt;/MasterDetailPage.Detail&gt;
  </code></pre>
  
  <p></p>
  
  <p>Here's my code in my viewmodel</p>
  
  <pre><code>public MasterDetailsViewModel()
  {
      MasterDetailPage masterDetailPage = new MasterDetailPage
      {
          Detail = new NavigationPage((Page)Activator.CreateInstance(typeof(HomePage)))
      };
  }
  </code></pre>
  
  <p>It's working when I put this line of code</p>
  
  <pre><code>Detail = new NavigationPage((Page)Activator.CreateInstance(typeof(HomePage)))
  </code></pre>
  
  <p>behind the code, but I want to achieve it from view model.</p>
  
  <p>Please help. Thank you in advance</p>