title: Binding UWP Page Loading/ Loaded to command with MVVM
body: <p>Preferrably written in PRISM (Prism.Core 6.2, Prism.Windows 6.02), but I also would like to know how to bind Command to Page Loading/ Loaded event in UWP with normal MVVM without Prism.</p>
  
  <p>In WPF, it is achievable with:</p>
  
  <pre><code>xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
  
  &lt;i:Interaction.Triggers&gt;
      &lt;i:EventTrigger EventName="Loaded"&gt;
          &lt;i:InvokeCommandAction Command="{Binding LoadedCommand}"/&gt;
      &lt;/i:EventTrigger&gt;
  &lt;/i:Interaction.Triggers&gt;
  </code></pre>
  
  <p>In the ViewModel</p>
  
  <pre><code>public ICommand LoadedCommand { get; private set; }
  public TheViewModelConstructor()
  {
       LoadedCommand = new DelegateCommand(Load);
  }
  private async void Load()
  {
      // Do stuff
  }
  </code></pre>
  
  <p>But in UWP, System.Windows.Interactivity does not exist. Simply binding with </p>
  
  <pre><code>Loaded="{Binding LoadedCommand}"
  </code></pre>
  
  <p>or </p>
  
  <pre><code>Loading="{Binding LoadingCommand}"
  </code></pre>
  
  <p>will get compile error "Object reference not set an instance of an object".</p>
  
  <p>The reason I wanted to do this is because there is an async method that needs to be done during or after Page is loaded (it cannot be inside ViewModel constructor). I could do it with code behind easily, but this is not MVVM.</p>
  
  <p>How can I bind this Command properly?</p>