2014-09-22

Breaking Change in Caliburn.Micro 2.0 for WPF Controls with Names

In Caliburn.Micro 1.x, this would work

<Button x:Name="OKButton"
 Content="OK"
 cal:Message.Attach="[Event Click]=[Action OK($source)];[Event PreviewMouseUp]=[Action Special($eventArgs)]">

However, in Caliburn.Micro 2.0, the events will not get called correctly. The problem is that the x:Name handling overrides any Message.Attach handling. The way to solve the problem is to remove or rename the x:Name attribute if you use Message.Attach. Thus, this works:

<Button
 Content="OK"
 cal:Message.Attach="[Event Click]=[Action OK($source)];[Event PreviewMouseUp]=[Action Special($eventArgs)]">

If you specify events through the Message.Attach code, you don't need the automatic binding of the x:Name attribute.

No comments :

Post a Comment

Note: Only a member of this blog may post a comment.