Unpredictable behavior of Action invocation in Caliburn Micro

Topics: Actions & Coroutines
Aug 10, 2012 at 1:13 AM
Edited Aug 10, 2012 at 12:16 PM

I develop app for Windows Phone 7 with using of Caliburn Micro.
Hear is a code of app's main parts.

Part of MainView:

<Grid x:Name="LayoutRoot" Background="Transparent">
        <controls:PanoramaItem x:Name="SubPanoramaItem"
                               DataContext="{Binding SubViewModel}">

                <toolkit:ListPicker ExpansionMode="FullScreenOnly" 
                                    ItemsSource="{Binding DataModeList}">

                            <TextBlock Text="{Binding Tag}" />


                            <StackPanel x:Name="item"
                                        Margin="5, 24, 0, 24"
                                        cal:Action.TargetWithoutContext="{Binding ElementName=SubPanoramaItem, Path=DataContext}"
                                        cal:Message.Attach="[Event Tap] = [Action Tap($dataContext)]"

                                <TextBlock FontSize="40" 
                                           Text="{Binding PopupText}" />




        <!-- Some other code -->


public class MainViewModel: Screen
    public SubViewModel SubViewModel { get; private set; }

    public MainViewModel(SubViewModel subViewModel)
        SubViewModel = subViewModel;

    // some other code


public class SearchViewModel : Screen
    private ObservableCollection<DateModeItem> _dataModeList = 
        new ObservableCollection<DateModeItem>()
                new DataItem
                { PopupText = "Item 1" },
                new DataItem
                { PopupText = "Item 2" },
                new DataItem
                { PopupText = "Item 3" },
                new DataItem
                { PopupText = "Item 4" }  

    public ObservableCollection<DateModeItem> DataModeList
            return _dataModeList;

        private set { _dataModeList = value; }

    public void Tap(object dataContext)
        var item = dataContext as DataItem;
        if (item != null)
            var r = new Random();
            switch (item.PopupText)
                case "Item 1":
                    item.Tag = r.Next(5);
                case "Item 2":
                    item.Tag = r.Next(5, 10);
                case "Item 3":
                    item.Tag = r.Next(10, 15);
                case "Item 4":
                    item.Tag = r.Next(15, 20);



public class DataItem 
    public string PopupText { get; set; }
    public int Tag { get; set; }


As you can see I've attached Action to each StackPanel of DataTemplate in ListPicker. When tap occurs on the item in the list then new random tag must be generated. This tag is inserted into ListPicker's textbox.

And this actions behave very strangely. When I tap on 1, 2 and 4 item, nothing happens at all. When I tap 3 item the app throws exception - "No target found for method Tap". And this what happens when I'm using ListPicker from Silverlight Toolkit.

I've also triend RadListPicker from Telerik's RadConrols library. When I've used it, invocation of action method was unpredictable. Sometimes action invokes method correct. Sometimes nothing happen at all. One I can say surely - with tap on the last item it works less often in the correct way.

What is going on? I can't understand.

P.S. I've also asked this question on Stackoverflow: http://stackoverflow.com/q/11893631/733648

Aug 10, 2012 at 2:25 AM
Edited Aug 10, 2012 at 3:10 PM

Additional info:

I've make a cleaning of all unnecessary stuff from my app and left only code that I described above in the previous post.

Now when I'm using ListPicker - nothing happens at all. List doesn't responds on taps. Sometimes app throws "No target found for method Tap" exception. When I'm using RadListPicker - almost always action not invoked and sometimes (very rarely) invoked correctly.

Aug 11, 2012 at 7:51 PM

don't know if it will make a difference but there was a nasty bug that caused the listpicker from the toolkit not to work correctly with the panorama's correctly at all not sure on the lastest drop cause the way MS indicated was they weren't going to fix or a fix wouldn't be available anytime soon.