Search code examples
c#wpfwindows-8.1caliburn.microcaliburn

How to disable "No target found for method X" exception


I have a style in my xaml-resources. It looks like this:

<Border cm:Message.Attach="[Event Tapped] = [Action UserCardTapped($dataContext)]">
 ...
</Border>

So I use this style in the different pages and different viewModels, but not all viewModels need to implement a method UserCardTapped. And here is the problem - if my viewModel doesn't contain a UserCardTapped method, Caliburn throws an exception with a message "No target found for method UserCardTapped".

Is it possible to disable binding to the method if it doesn't exist?


Why down-voting? Is there more elegant way?


Solution

  • ActionMessage.ThrowsExceptions = false; will do the trick.