title: Cal.Message.Attach - No target found for method
body: <p>I designed an interface in WPF with Caliburn.Micro. I have customized radiobuttons which are triggered a method by cal:Message.Attach property when they're checked. But when I check one of the radiobuttons having this property, I get the error of: <em>No target found for method</em> </p>
  
  <p>My FarKornaView.xaml:</p>
  
  <pre><code>&lt;Grid 
      Style="{StaticResource ContentRoot}"
      x:Class="IKA.Views.FarKornaView"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:mui="http://firstfloorsoftware.com/ModernUI"
      xmlns:cal="http://www.caliburnproject.org"
      xmlns:model="clr-namespace:IKA.ViewModels"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:ika="clr-namespace:IKA"
      mc:Ignorable="d"
      d:DataContext="{x:Type model:FarKornaViewModel}"&gt;
  &lt;Grid.Resources&gt;
      &lt;ResourceDictionary&gt;
          &lt;ResourceDictionary.MergedDictionaries&gt;
              &lt;ResourceDictionary Source="../Resources/toggle.xaml"&gt;&lt;/ResourceDictionary&gt;
          &lt;/ResourceDictionary.MergedDictionaries&gt;
          &lt;ControlTemplate x:Key="RadioButtonStyle" TargetType="ika:RadioButtonExtension"&gt;
              &lt;ika:RadioButtonExtension Style="{StaticResource AnimatedSwitch}"  Width="100" Height="40" HorizontalAlignment="Left" Content="{TemplateBinding ContentPresenter.Content}"   GroupName="{TemplateBinding GroupName}" IsChecked="{TemplateBinding IsChecked}" /&gt;
          &lt;/ControlTemplate&gt;
      &lt;/ResourceDictionary&gt;
  &lt;/Grid.Resources&gt;
  &lt;Grid.RowDefinitions&gt;
      &lt;RowDefinition Height="Auto" /&gt;
      &lt;RowDefinition Height="Auto" /&gt;
      &lt;RowDefinition Height="Auto" /&gt;
      &lt;RowDefinition Height="Auto" /&gt;
      &lt;RowDefinition Height="Auto" /&gt;
      &lt;RowDefinition Height="Auto" /&gt;
  &lt;/Grid.RowDefinitions&gt;
  &lt;Grid.ColumnDefinitions&gt;
      &lt;ColumnDefinition Width="*"&gt;&lt;/ColumnDefinition&gt;
      &lt;ColumnDefinition Width="*"&gt;&lt;/ColumnDefinition&gt;
  &lt;/Grid.ColumnDefinitions&gt;
  &lt;TextBlock Grid.Column="0" Grid.Row="0" Text="Sol Far"  Style="{StaticResource Heading2}"/&gt;
  &lt;TextBlock Grid.Column="1" Grid.Row="0" Text="Sağ Far"  Style="{StaticResource Heading2}" /&gt;
  &lt;TextBlock Grid.Column="0" Grid.Row="3" Text="Toros Farı" Style="{StaticResource Heading2}" /&gt;
  &lt;TextBlock Grid.Column="1" Grid.Row="3" Text="Angel Eyes"  Style="{StaticResource Heading2}"/&gt;
  
  &lt;ika:RadioButtonExtension x:Name="far_1" Grid.Column="0" Grid.Row="1" GroupName="Sol" Template="{StaticResource RadioButtonStyle}"  Content="Sürekli Yak" /&gt;
  &lt;ika:RadioButtonExtension x:Name="far_2" Grid.Column="0" Grid.Row="2" GroupName="Sol" Template="{StaticResource RadioButtonStyle}"  Content="Yak Söndür"/&gt;
  &lt;ika:RadioButtonExtension x:Name="far_3" Grid.Column="1" Grid.Row="1" GroupName="Sağ" Template="{StaticResource RadioButtonStyle}"  Content="Sürekli Yak"  /&gt;
  &lt;ika:RadioButtonExtension x:Name="far_4" Grid.Column="1" Grid.Row="2" GroupName="Sağ" Template="{StaticResource RadioButtonStyle}"  Content="Yak Söndür"   /&gt;
  &lt;ika:RadioButtonExtension x:Name="far_5" Grid.Column="0" Grid.Row="4" GroupName="Toros" Template="{StaticResource RadioButtonStyle}" Content="Sürekli Yak"  cal:Message.Attach="RadioButtonHandler(far_5.GroupName,far_5.Content,far_5.IsChecked)"/&gt;
  &lt;ika:RadioButtonExtension x:Name="far_6" Grid.Column="0" Grid.Row="5" GroupName="Toros" Template="{StaticResource RadioButtonStyle}" Content="Yak Söndür"   cal:Message.Attach="RadioButtonHandler(far_6.GroupName,far_6.Content,far_6.IsChecked)"/&gt;
  &lt;ika:RadioButtonExtension x:Name="far_7" Grid.Column="1" Grid.Row="4" GroupName="Angel" Template="{StaticResource RadioButtonStyle}" Content="Sürekli Yak"  cal:Message.Attach="RadioButtonHandler(far_7.GroupName,far_7.Content,far_7.IsChecked)"/&gt;
  &lt;ika:RadioButtonExtension x:Name="far_8" Grid.Column="1" Grid.Row="5" GroupName="Angel" Template="{StaticResource RadioButtonStyle}" Content="Yak Söndür"   cal:Message.Attach="RadioButtonHandler(far_8.GroupName,far_8.Content,far_8.IsChecked)"/&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>My codes to style radiobutton as a toggle button like iPhone-style from there: <a href="http://marcangers.com/animated-switch-togglebutton-style-in-wpf/" rel="nofollow">http://marcangers.com/animated-switch-togglebutton-style-in-wpf/</a></p>
  
  <pre><code>    &lt;ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:cal="http://www.caliburnproject.org"
    xmlns:ika="clr-namespace:IKA"&gt;
      &lt;Style x:Key="AnimatedSwitch" TargetType="{x:Type ika:RadioButtonExtension}"&gt;
          &lt;Setter Property="Foreground" Value="Black" /&gt;
          &lt;Setter Property="Background" Value="#FAFAFB" /&gt;
          &lt;Setter Property="BorderBrush" Value="#EAEAEB" /&gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="ika:RadioButtonExtension"&gt;
                      &lt;Viewbox Stretch="Uniform"&gt;
                          &lt;Canvas Name="Layer_1" Width="100" Height="20" Canvas.Left="10" Canvas.Top="0"&gt;
                              &lt;ContentPresenter Canvas.Left="0" Width="70" Height="20" HorizontalAlignment="Left"/&gt;
                              &lt;!--&lt;ContentPresenter Canvas.Left="0" Width="20" Height="20" ContentSource="Content" VerticalAlignment="Center" RecognizesAccessKey="True" /&gt;--&gt;
                              &lt;Ellipse  Canvas.Left="80" Width="20" Height="20" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="0.9"/&gt;
                              &lt;Ellipse  Canvas.Left="95" Width="20" Height="20" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="0.9"/&gt;
                              &lt;Border   Canvas.Left="90" Width="15" Height="20" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0,0.51,0,0.51" /&gt;
                              &lt;Ellipse x:Name="ellipse"  Canvas.Left="80" Width="20" Height="20" Fill="White" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="0.3"&gt;
                                  &lt;Ellipse.RenderTransform&gt;
                                      &lt;TranslateTransform X="0" Y="0" /&gt;
                                  &lt;/Ellipse.RenderTransform&gt;
                                  &lt;Ellipse.BitmapEffect&gt;
                                      &lt;DropShadowBitmapEffect Softness="0.1" ShadowDepth="0.7" Direction="270" Color="#BBBBBB"/&gt;
                                  &lt;/Ellipse.BitmapEffect&gt;
                              &lt;/Ellipse&gt;
                          &lt;/Canvas&gt;
                      &lt;/Viewbox&gt;
                      &lt;ControlTemplate.Triggers&gt;
                          &lt;Trigger Property="IsChecked" Value="True" &gt;
                              &lt;Trigger.EnterActions&gt;
                                  &lt;BeginStoryboard&gt;
                                      &lt;Storyboard&gt;
                                          &lt;ColorAnimation Storyboard.TargetProperty="Background.Color" To="#52D468" Duration="0:0:0.2" /&gt;
                                          &lt;ColorAnimation Storyboard.TargetProperty="BorderBrush.Color" To="#41C955" Duration="0:0:0.2" /&gt;
                                          &lt;DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Ellipse.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="ellipse"&gt;
                                              &lt;SplineDoubleKeyFrame KeyTime="0" Value="0"/&gt;
                                              &lt;SplineDoubleKeyFrame KeyTime="0:0:0.4" Value="15" KeySpline="0, 1, 0.6, 1"/&gt;
                                          &lt;/DoubleAnimationUsingKeyFrames&gt;
                                      &lt;/Storyboard&gt;
                                  &lt;/BeginStoryboard&gt;
                              &lt;/Trigger.EnterActions&gt;
                              &lt;Trigger.ExitActions&gt;
                                  &lt;BeginStoryboard&gt;
                                      &lt;Storyboard&gt;
                                          &lt;ColorAnimation Storyboard.TargetProperty="Background.Color" To="#FAFAFB" Duration="0:0:0.2" /&gt;
                                          &lt;ColorAnimation Storyboard.TargetProperty="BorderBrush.Color" To="#EAEAEB" Duration="0:0:0.2" /&gt;
                                          &lt;DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Ellipse.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="ellipse"&gt;
                                              &lt;SplineDoubleKeyFrame KeyTime="0" Value="15"/&gt;
                                              &lt;SplineDoubleKeyFrame KeyTime="0:0:0.3" Value="0" KeySpline="0, 0.5, 0.5, 1"/&gt;
                                          &lt;/DoubleAnimationUsingKeyFrames&gt;
                                      &lt;/Storyboard&gt;
                                  &lt;/BeginStoryboard&gt;
                              &lt;/Trigger.ExitActions&gt;
                          &lt;/Trigger&gt;
                      &lt;/ControlTemplate.Triggers&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
  &lt;/ResourceDictionary&gt;
  </code></pre>
  
  <p>Also my RadioButtonExtension class which makes radiobuttons uncheckable and gaining feature of classic Radiobutton groups to these styled Radiobuttons:</p>
  
  <pre><code>      public class RadioButtonExtension : RadioButton
    {
      public static int WasChecked { get; set; }
  
      public bool? IsCheckedChanged
      {
          get
          {
              return (bool?)GetValue(IsCheckedChangedProperty);
          }
          set
          {
              SetValue(IsCheckedChangedProperty, value);
          }
      }
  
      // Using a DependencyProperty as the backing store for IsChanged.  
     //This enables animation, styling, binding, etc...
    public static readonly DependencyProperty IsCheckedChangedProperty =
          DependencyProperty.Register("IsChanged", typeof(bool?), 
            typeof(RadioButtonExtension),
        new FrameworkPropertyMetadata(false, 
        FrameworkPropertyMetadataOptions.Journal |
        FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
          CheckedChanged));
  
       public static void CheckedChanged(DependencyObject d, 
                DependencyPropertyChangedEventArgs e)
       {
         ((RadioButtonExtension)d).IsChecked = (bool)e.NewValue;
       }
  
       public RadioButtonExtension()
       {
          this.Click += RadioButtonExtension_Click;
          this.Checked += new RoutedEventHandler(RadioButtonExtension_Checked); 
       }
  
       void RadioButtonExtension_Click(object sender, System.Windows.RoutedEventArgs e)
       {
           if (WasChecked &gt; 0 &amp;&amp; IsCheckedChanged==true)
           {
               this.IsChecked = false;
               WasChecked = 0;
  
           }
           else if (WasChecked == 0 &amp;&amp; IsCheckedChanged == true)
           {
               WasChecked = 1;
           }
       }
  
      void RadioButtonExtension_Checked(object sender, System.Windows.RoutedEventArgs e)
      {
          if (this.IsChecked == true)
          {
              DependencyObject parent = VisualTreeHelper.GetParent(this);
              DependencyObject parent2 = VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(parent));
              var a = parent2.Ancestors().OfType&lt;RadioButtonExtension&gt;()
                  .OrderBy(x =&gt; x.GroupName)
                  .Where(x =&gt; x.GroupName == this.GroupName &amp;&amp; x.Name != this.Name)
                  .AsEnumerable();
              foreach (RadioButtonExtension button in a)
              {
                  button.IsChecked = false;
              }
              IsCheckedChanged = true;
              WasChecked = 0;
          }
          else
          {
              IsCheckedChanged = false;
          }
      }
    }
  </code></pre>
  
  <p>And finally my FarKornaViewModel which contains <code>RadioButtonHandler</code> method.</p>
  
  <pre><code> public sealed class FarKornaViewModel : Screen, IMainScreenTabItem
  {
      private FarKontrol _farKontrol;
      public FarKornaViewModel(FarKontrol farKontrol)
      {
          _farKontrol = farKontrol;
          DisplayName = "Far Kontrol";
      }
      public void RadioButtonHandler(string groupname, string content, bool isChecked)
      {
          FarDeger.FarIsim = groupname;
          FarDeger.Secim = content;
          FarDeger.isChecked = isChecked;
          _farKontrol.SendCommand();
      }
  }
  </code></pre>
  
  <p>MainView.xaml:</p>
  
  <pre><code>&lt;mui:ModernWindow x:Class="IKA.Views.MainView"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:mui="http://firstfloorsoftware.com/ModernUI"
      xmlns:model="clr-namespace:IKA.ViewModels"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      mc:Ignorable="d"
      d:DataContext="{x:Type model:MainViewModel}"
      Title="{Binding WindowTitle}"
      Height="400" Width="700"&gt;
  &lt;mui:ModernWindow.MenuLinkGroups&gt;
      &lt;mui:LinkGroup DisplayName="Kontrol" &gt;
          &lt;mui:LinkGroup.Links&gt;
              &lt;mui:Link DisplayName="Far ve Korna Kontrol" Source="..\Views\FarKornaView.xaml"/&gt;
              &lt;mui:Link DisplayName="Bağlantı" Source="..\Views\ConnectionView.xaml"/&gt;
          &lt;/mui:LinkGroup.Links&gt;
      &lt;/mui:LinkGroup&gt;
      &lt;mui:LinkGroup DisplayName="İKA" &gt;
          &lt;mui:LinkGroup.Links&gt;
              &lt;mui:Link DisplayName="Hakkında" /&gt;
              &lt;mui:Link DisplayName="Sistem" /&gt;
              &lt;/mui:LinkGroup.Links&gt;
          &lt;/mui:LinkGroup&gt;
  &lt;/mui:ModernWindow.MenuLinkGroups&gt;
  </code></pre>
  
  <p></p>
  
  <p>MainViewModel.cs :</p>
  
  <pre><code>    public class MainViewModel : Screen
  {
      private const string WindowTitleDefault = "IKA - Control Panel";
      private string _windowTitle = WindowTitleDefault;
      public MainViewModel()
      {
      }
      public string WindowTitle
      {
          get { return _windowTitle; }
          set
          {
              _windowTitle = value;
              NotifyOfPropertyChange(() =&gt; WindowTitle);
          }
      }
  </code></pre>
  
  <p><strong>EDIT 1</strong>:
  I checked the radiobutton's <code>DataContext</code> from RadioButtonExtensions and I noticed that it seems as MainViewModel, not FarKornaViewModel but I can't figure out why.</p>
  
  <p><strong>EDIT 2</strong>:
  Even I don't set a datacontext, it sets MainViewModel automatically. Something sets MainViewModel as default VM maybe, but I don't know it's because of Caliburn or Modern.UI or something else.</p>
  
  <p><strong>EDIT 3</strong>:
  I found that FarKornaView runs firstly because of MenuLinkGroups in MainView so FarKornaViewModel can't run, the FarKornaView must be showed in MainView. I guess I should trigger ViewModel instead of View from links.</p>