title: C# WPF Caliburn Micro TreeViewItem.Expanded Event Not Firing
body: <p>I'm using Caliburn Micro Message.Attach through XAML to try and bind Events to a View Model, but I cannot get the <code>TreeViewItem.Expanded</code> Event to fire. Other events like <code>SetSelectedItem</code> work fine.</p>
  
  <p>I found another question on this on SO <a href="https://stackoverflow.com/a/15737279/9274885">here</a> but it was not helpful in my case as no context for the response was provided.</p>
  
  <p>The only other information I can find is the following GitHub <a href="https://github.com/Caliburn-Micro/Caliburn.Micro/issues/284" rel="nofollow noreferrer">issue</a>.</p>
  
  <blockquote>
    <p>Internally Caliburn.Micro turns
    <code>&lt;Button cm:Message.Attach="[Event Click] = [Action Test]" /&gt;</code></p>
    
    <p>into</p>
  
  <pre><code>&lt;Button&gt;
     &lt;i:Interaction.Triggers&gt;
         &lt;i:EventTrigger EventName="Click"&gt;
             &lt;cm:ActionMessage MethodName="Test" /&gt;
         &lt;/i:EventTrigger&gt;
     &lt;/i:Interaction.Triggers&gt;
  &lt;/Button&gt;
  </code></pre>
    
    <p>As you noted, EventTrigger doesn't support attached events. A quick look around brought up <a href="https://sergecalderara.wordpress.com/2012/08/23/how-to-attached-an-mvvm-eventtocommand-to-an-attached-event/" rel="nofollow noreferrer">How to attached an MVVM EventToCommand to an Attached event</a> which shows how to create a RoutedEventTrigger that  you could plug into the full syntax.</p>
  </blockquote>
  
  <p>Again, I tried this approach, but don't fully understand how to implement this. It fires the event in the custom class, but never gets passed on to my handler in the View Model.</p>
  
  <p>Here is my XAML (without the GitHub suggestion):</p>
  
  <pre><code>    &lt;TreeView x:Name="FolderView"
                                cal:Message.Attach="[Event TreeViewItem.Expanded] = [Action Expanded($this)]; 
                                [Event SelectedItemChanged] = [Action SetSelectedItem($this.SelectedItem)]"&gt;
                          &lt;TreeView.Resources&gt;
                              &lt;HierarchicalDataTemplate DataType="{x:Type models:LogicalDriveItem}" 
                                                        ItemsSource="{Binding Directories}"  &gt;
                                  &lt;StackPanel Orientation="Horizontal"&gt;
                                      &lt;TextBlock VerticalAlignment="Center" Text="{Binding Path=DriveLetter}"&gt;&lt;/TextBlock&gt;
                                  &lt;/StackPanel&gt;
                              &lt;/HierarchicalDataTemplate&gt;
                              &lt;HierarchicalDataTemplate DataType="{x:Type models:DirectoryItem}"
                                                        ItemsSource="{Binding Directories}"&gt;
                                  &lt;TextBlock VerticalAlignment="Center" Text="{Binding Path=Path}"&gt;&lt;/TextBlock&gt;
                              &lt;/HierarchicalDataTemplate&gt;
                          &lt;/TreeView.Resources&gt;
                      &lt;/TreeView&gt;
  </code></pre>
  
  <p>And my view model code:</p>
  
  <pre><code>    public void Expanded(object sender, RoutedEventArgs e)
      {
          // This won't fire
      }
  
      public void Expanded(object sender)
      {
          // Or this
      }
  
      public void SetSelectedItem(object sender)
      {
          // But this will
      }
  </code></pre>