[WinRT] Attaching message to non-routed events

Topics: Actions & Coroutines
Dec 19, 2012 at 11:00 AM
Edited Dec 19, 2012 at 3:59 PM


I am currently developing on WinRT custom control that exposes one event declared as follows:
       public event EventHandler XChanged;
        protected virtual void XChanged()
            var handler = XChanged;
            if (handler != null)
                handler(this, new EventArgs());

On view i try to bind that event to view model using:
cal:Message.Attach="[Event XChanged] = [Action XChangedHandler()]"

handler is not firing. When i add some routed event to that message definition( like Tapped ) routed one works. I use 1.4 caliburn version.

I have also done quick investigation on previously used by my fork from marker_metro. I have discovered that action is not properly attached. The problem is that in method private void RegisterEvent(object obj, string eventName) from EventTriggerBase. Attached event is check by method EventTriggerBase.IsValidEvent if it's routed. Does it look the same in official version of caliburn.micro 1.4? In other words does caliburn support attaching actions to non-routed events? This scenario was supported in caliburn's WP7.1 version.



Dec 19, 2012 at 1:20 PM
Edited Dec 19, 2012 at 1:21 PM


this is actually an issue with WUI (see https://github.com/jlaanstra/Windows.UI.Interactivity/issues/11) and not Caliburn.Micro itself.

In WUI it should be fixed already, but Caliburn.Micro is not working with this new WUI version (see https://caliburnmicro.codeplex.com/workitem/249).
If you need this: Vote for the issue, please.

Dec 19, 2012 at 3:52 PM

Thank you for quick answer.

Jan 29, 2013 at 8:25 AM

ok, i have try it using many samples.I found it's not the reason of the Windows.Ui.Interactivity ,not the Caliburn.Micro. The reason is the WinRT. The WUI use


WindowsRuntimeMarshal.AddEventHandler<Delegate>(this.addMethod, this.removeMethod, handler);


the Windows Runtime method to deal the event,So We must registe the event in the WindowRuntimeComponent, but the Windows Runtime Component only access the RoutedEventHandler. So ..... ~_~.