title: Caliburn.micro and a usercontrol click handler
body: <p>I have created a very simple user control, an ImageButton</p>
  
  <pre><code>&lt;UserControl x:Class="SampleApp.Controls.ImageButton"
               Name="ImageButtonControl"
               xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
               xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
               xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
               d:DesignHeight="300"
               d:DesignWidth="300"
               mc:Ignorable="d"&gt;
      &lt;Button&gt;
          &lt;Grid&gt;
              &lt;Grid.RowDefinitions&gt;
                  &lt;RowDefinition Height="1*" /&gt;
                  &lt;RowDefinition Height="6*" /&gt;
                  &lt;RowDefinition Height="2*" /&gt;
                  &lt;RowDefinition Height="1*" /&gt;
              &lt;/Grid.RowDefinitions&gt;
              &lt;Image Grid.Row="1" Source="{Binding ElementName=ImageButtonControl, Path=Image}" VerticalAlignment="Stretch" HorizontalAlignment="Center" /&gt;
              &lt;TextBlock Grid.Row="2" Text="{Binding ElementName=ImageButtonControl, Path=Text}" VerticalAlignment="Stretch" HorizontalAlignment="Center" /&gt;
          &lt;/Grid&gt;
      &lt;/Button&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>With code behind:</p>
  
  <pre><code>using System.Windows;
  using System.Windows.Controls;
  using System.Windows.Media;
  
  namespace SampleApp.Controls
  {
      /// &lt;summary&gt;
      /// Interaction logic for ImageButton.xaml
      /// &lt;/summary&gt;
      public partial class ImageButton : UserControl
      {
          public ImageButton()
          {
              InitializeComponent();
          }
  
          public string Text
          {
              get { return (string)GetValue(TextProperty); }
              set { SetValue(TextProperty, value); }
          }
  
          public static readonly DependencyProperty TextProperty =
            DependencyProperty.Register("Text", typeof(string), typeof(ImageButton), new UIPropertyMetadata(""));
  
          public ImageSource Image
          {
              get { return (ImageSource)GetValue(ImageProperty); }
              set { SetValue(ImageProperty, value); }
          }
  
          public static readonly DependencyProperty ImageProperty =
             DependencyProperty.Register("Image", typeof(ImageSource), typeof(ImageButton), new UIPropertyMetadata(null)); 
      }
  }
  </code></pre>
  
  <p>Now I want to use that in my little sample application like</p>
  
  <pre><code>xmlns:controls="clr-namespace:SampleApp.Controls"
  
  &lt;controls:ImageButton Grid.Row="1"
                                Grid.Column="1"
                                Margin="2"
                                Image="/Images/link.png"
                                Text="DoSomething"&gt;
              &lt;i:Interaction.Triggers&gt;
                  &lt;i:EventTrigger EventName="Click"&gt;
                      &lt;cal:ActionMessage MethodName="DoSomething" /&gt;
                  &lt;/i:EventTrigger&gt;
              &lt;/i:Interaction.Triggers&gt;
          &lt;/controls:ImageButton&gt;
  </code></pre>
  
  <p>If I give it a x:Name, like</p>
  
  <pre><code>&lt;controls:ImageButton x:Name="DoSomething" 
  </code></pre>
  
  <p>e.g. DoSomething the method <code>DoSomething</code> with that name is directly called when the view is shown, i.e. when I active the viewmodel that contains that button, just like I click the Button (if it was a normal button and not a usercontrol, it would work that way), but the button-click handler is never called on clicking.</p>
  
  <p>Now I tried to add an ActionMessage as seen above, but it does not work either...</p>
  
  <p>What is wrong here?</p>