title: How to get when a view is activated?
body: <p>Making it simple, I have a prism module with several view.</p>
  
  <p>One of these is a usercontrol with a grid in it and I need to get when this view is active to reload its datacontext.</p>
  
  <p>I know i have to use the <code>IActiveAware</code> interface, but I can't figure out how...</p>
  
  <p><strong>edit:</strong></p>
  
  <p>MyUserControl.xaml</p>
  
  <pre><code>&lt;UserControl x:Class="[...]
               mc:Ignorable="d"&gt;
  
      &lt;UserControl.Resources&gt;
          &lt;dc:MyViewModel x:Key="MyViewModel" /&gt;
      &lt;/UserControl.Resources&gt;
  
      &lt;Grid DataContext="{StaticResource MyViewModel}"&gt;
          &lt;Grid.RowDefinitions&gt;
      [...]
  </code></pre>
  
  <p>MyUserControl.xaml.cs</p>
  
  <pre><code>public partial class MyUserControl: UserControl, IActiveAware
  {
      public MyUserControl(IRegionManager _regionManager)
      {
          regionManager = _regionManager;
          InitializeComponent();         
      }
  
      public event EventHandler&lt;EventArgs&gt; Activated;
  
      public event EventHandler&lt;EventArgs&gt; Deactivated;
  
      private bool _IsActive;
      public bool IsActive
      {
          get
          {
              return _IsActive;
          }
          set
          {
              _IsActive = value;
              IActiveAware vmAware = DataContext as IActiveAware;
              if (vmAware != null)
                  vmAware.IsActive = value;
  
          }
      }
      public event EventHandler IsActiveChanged = delegate { };
  [...]
  </code></pre>
  
  <p>MyViewModel.cs</p>
  
  <pre><code>public class MyViewModel: IActiveAware
  {
      private bool isActive { get; set; }
      public bool IsActive
      {
          get
          {
              return isActive;
          }
          set
          {
              isActive = value;
              LoadData();
              IsActiveChanged(this, EventArgs.Empty);
          }
      }
  
      public event EventHandler IsActiveChanged = delegate { };
  [...]
  </code></pre>