ActionMessage and DevExpress BarButtonItem

Jul 9, 2010 at 9:40 PM
Edited Jul 9, 2010 at 9:47 PM
I am trying to get a sample with DevExpress DxBars to work with Caliburn Micro. It worked fine with Caliburn, but with Micro I get an error message when starting up: "Cannot attach type "ActionMessage" to type "BarButtonItem". Instances of type "ActionMessage" can only be attached to objects of type "FrameworkElement"." Here's the xaml:


            <dxb:BarButtonItem x:Name="CreateRecipe" Content="Ny" cal:Message.Attach="[Event ItemClick] = [Action CreateRecipe()]"/>
I guess it has to do with the move to System.Windows.Interactivity for ActionMessages. Is there any work around to get it to work with BarButtonItem? Thanks, Magnus Haggren
Jul 10, 2010 at 3:45 AM
What is the inheritance hierarchy of BarButtonItem. Is this WPF or Silverlight?
Jul 10, 2010 at 7:25 AM

The code is for WPF. Here's from the help documentation:

Inheritance Hierarchy

Jul 10, 2010 at 12:38 PM
That's what I suspected. The problem is that BarButtonItem inherits from FrameworkContentElement and the behavior only supports FrameworkElement. I'll create a ticket and investigate just how difficult this would be to fix. It's a bit of a pain that MS didn't impelement a common interface between these two base classes. If you decompile WPF, you will see that they are type casting and type checking everywhere as well as wrapping things with decorators just to account for these two base classes, when they could have created an interface and helped themselves and all of us out. Anyways....I'll investigate.
Jul 10, 2010 at 5:32 PM
I'm not going to support this with Caliburn.Micro. Here's why: 1. Supporting both WPF's FrameworkElement and FrameworkContentElement would add a lot of complexity to the codebase and increase the assembly size noticeably. 2. IMO, DevExpress is in the wrong with their usage of FrameworkContentElement. They should be inheriting from FrameworkElement. FCE is primarily intended to be used for elements that live inside a flow document. That doesn't seam to be the case here. I'm not sure why they chose to use FCE. 3. You can always use the full version of Caliburn. It supports FE and FCE.
Sep 17, 2010 at 8:10 PM

I've reported this issue with DevExpress and they are going to change this so that they are descending from FrameworkElement instead.

Aug 14, 2012 at 11:06 AM

Since then DevExpress decided not to change this. As a workaround I created a new package Caliburn.Micro.FrameworkContentElement. It is a subset of the Caliburn.Micro codebase containing only the classes required to support Message.Attach on a FrameworkContentElement descendant. (So, you can't use it for any other purpose than attaching messages and if you need any other Caliburn.Micro feature, you have to use the original one.)