Attached message fires only once, through Caliburn.Micro.Message's OnAttachChanged

Topics: Actions & Coroutines
Dec 1, 2011 at 9:13 PM
Edited Dec 1, 2011 at 9:19 PM

Hello, I am trying to attach a message for a third party control.   So when its items are selected, a function fires.

In my View, I've got on a SyncFusion Gallery with this on it:


cal:Message.Attach="[Event SelectionChanged] = [Action Awwyeah()]"


But this only works once.  I can click on the items for the first time, or switch to the View from another.  Each time, it is caught through Caliburn.Micro.Message's OnAttachChanged.  I don't know if that is significant. 

For a test, I made another View and used the View's xaml's code-behind to catch the SelectionChanged event.  It catches it each time, so my approach is on the right track me thinks.


Any ideas? Need more info?

Can anyone point me to the areas of the source code I should be looking at to debug why and event is not firing?

Dec 2, 2011 at 2:18 AM

What control are you working with specifically?


Dec 2, 2011 at 1:45 PM



Dec 2, 2011 at 5:08 PM

hi again,

I was looking thru the docs for that control on SyncFusion's site and I don't really see anything helpful.  I don't believe this is a caliburn issue.  How are you populating the control?  Do you use the AllowMultiSelect="True", other than that I am not sure how this control is wired up since there isn't much information on binding to a collection or the like.

Dec 2, 2011 at 6:24 PM
Edited Dec 2, 2011 at 6:34 PM

Thanks for doing that!  I guess I just expected the event I was able to wire into a fucntion in the xaml.cs to be the same thing I try to wire up in the XAML with Message.Attach

for example:

<UserControl x:Class="eVision.Views.TestView"
<...>>     <StackPanel>         <sync:Gallery x:Name="Sweet">             <sync:GalleryGroup>                 <Rectangle></Rectangle>             </sync:GalleryGroup>             <sync:GalleryGroup Opacity=".4">                 <Rectangle></Rectangle>             </sync:GalleryGroup>         </sync:Gallery>     </StackPanel> </UserControl>


public partial class TestView : UserControl
        public TestView()
            layout.Sweet.SelectionChanged += (sender, e) =>
                int t = 4; //whatever

catches the event on each click like you'd expect.

So I thought the equivalent for caliburn/MVVM:

<UserControl x:Class="eVision.Views.MonitorView"
            <TextBlock Name="DisplayName"></TextBlock>
            <sync:Gallery >
                <sync:GalleryGroup  Name="Items" cal:Message.Attach="[Event Click] = [Action test()]">
              </sync:GalleryGroup>             </sync:Gallery>         </StackPanel>     </Grid> </UserControl>


class MonitorViewModel : Screen
 void test()         {             int y = 3;         }

would also work.  I have added items by calling the GalleryGroup "Items" and filling it in on the constructor.. I have filled it in with xaml objects.  I have also but the message.attach on the gallery itself, but no go!

Eitherway, the event fires only once.  Would you know what part of the caliburn source would tell me why it isn't firing the event?  Or why it fires once OnAttachChanged but never again?

Dec 3, 2011 at 1:45 AM
Edited Dec 3, 2011 at 1:49 AM

Yea part of the problem though is they don't really include API information for their controls.  So without knowing the structure you can't really know how to attach events to the appropriate items.  So the only thing I can think of is that you are trying to get to the Items stored within the group to click on.  Therefore you would have to figure out how the individual items in the GalleryGroup can be attached too... 

try... [Event SelectionChanged] = [Action test()]

Essentially you are telling the event to react to the selected item in the Gallery.  Since I have no idea if the SelectionChanged event even exists for that control...   Used in this from could yield what you are looking for... [Event SelectionChanged] = [Action test($dataContext)]    $dataContext will be equivalent to the item selected.   So the signature for test would be

public void test(SelectionChangedArgs e){


or what ever that control has for SelectionChanged event...

Dec 5, 2011 at 1:23 PM
Edited Dec 5, 2011 at 4:42 PM

Aye, I did try that first.  I think we are buying the controls + the source code so I guess we will eventually work it out. 

Thank you for your time, friend!


So I have moved on and started to play around with other tasks I will have to do using SyncFusion controls and caliburnTurns out they have a gallery, with a gallery group, which is filled with gallery items.  If I take a View-First approach, I can go into a test XAML page with their gallery and reference my views and I can get the content of a gallery item to render my view. 

However, if I use code to set the content of the gallery item to my ViewModel, it does not find my view to render.  However, just below that I have a stack panel which just adds the view models and they are found no problem, what do I need to do to help the Gallery along?  How do I even debug caliburn to know what it is doing?  Can I get any general pointers on where I should be trying to look or set breakpoints to know where it enters the world of caliburn?