Foo.Bar not supported in Message.Attach?

Sep 22, 2010 at 2:14 PM

When trying the code below I get an exception telling me that "No target found for method Foo.Bar".

Is this a bug? Omission? My fault? Or is there a reason for not supporting this?

My view

<Button Content="Button" Height="23" Width="75" cal:Message.Attach="Foo.Bar" />

My ViewModel

public class TestViewModel
{
	public TestViewModel()
	{
		Foo = new FooBar();
	}
	public FooBar Foo { get; set; }
}

public class FooBar
{
	public void Bar()
	{
	}
}

Sep 22, 2010 at 3:30 PM

This syntax is not supported by design, to avoid misuse of Message.Attach to write small pieces of logic in the view (see warning in Message.Attach chapter here: http://caliburnmicro.codeplex.com/wikipage?title=All%20About%20Actions)

If you want to avoid writing a method in TestViewModel, you can use the following syntax to replace the action target for the Button:

<Button ... cal:Action.TargetWithoutContext="{Binding Foo}" cal:Message.Attach="Bar" />



Sep 23, 2010 at 7:28 AM

Awesome!

This library and community is tremendously helpful when learning WPF and MVVM.