문제

I've a problem with caliburn ActionMessage and windows phone 8.1 . Here my code:

       <ListBox x:Name="Categories" Grid.Row="1" ItemContainerStyle="{StaticResource TileListBoxItemStyle}">
        <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <StackPanel />
            </ItemsPanelTemplate>
        </ListBox.ItemsPanel>
        <ListBox.ItemTemplate>
            <DataTemplate>
                <Button>
                    <i:Interaction.Behaviors>
                        <core:EventTriggerBehavior EventName="Click">
                            <micro:ActionMessage MethodName="GoToPage">
                                <micro:Parameter Value="{Binding Path=PageId}" />
                            </micro:ActionMessage>
                        </core:EventTriggerBehavior>
                    </i:Interaction.Behaviors>
                    <TextBlock Text="{Binding Path=PageDescription}" TextWrapping="Wrap"
                           HorizontalAlignment="Center" VerticalAlignment="Center" />
                </Button>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>

On my app, the buttons will be created at runtime. But when I press button, I have this error:

System.Exception: No target found for method GoToPage. at Caliburn.Micro.ActionMessage.Invoke(Object eventArgs) at Caliburn.Micro.TriggerAction`1.Execute(Object sender, Object parameter) at Microsoft.Xaml.Interactivity.Interaction.ExecuteActions(Object sender, ActionCollection actions, Object parameter) at Microsoft.Xaml.Interactions.Core.EventTriggerBehavior.OnEvent(Object sender, Object eventArgs)

Why? With WP 8.0 this code works.

Thanks!

도움이 되었습니까?

해결책

You have to specify AssociatedObject on the ActionMessage. In your case this is the button.

Following issue describes the details: https://github.com/Caliburn-Micro/Caliburn.Micro/issues/24

다른 팁

Another reason of this exception may be.

Exception that @Max has described, also occures if you did not register your viewmodel:

_container = new WinRTContainer();
_container.RegisterWinRTServices();
_container.PerRequest<TestViewModel>(); // <-- without that line I got the same error

PS: Valid for Caliburn.Micro v.2.0.1

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top