C# Caliburn 2.0.0和WP 8.1:ActionMessage don';未找到目标方法
我对caliburn ActionMessage和windows phone 8.1有问题。这是我的代码:C# Caliburn 2.0.0和WP 8.1:ActionMessage don';未找到目标方法,c#,xaml,windows-phone,windows-phone-8.1,caliburn.micro,C#,Xaml,Windows Phone,Windows Phone 8.1,Caliburn.micro,我对caliburn ActionMessage和windows phone 8.1有问题。这是我的代码: <ListBox x:Name="Categories" Grid.Row="1" ItemContainerStyle="{StaticResource TileListBoxItemStyle}"> <ListBox.ItemsPanel> <ItemsPanelTemplate>
<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>
在我的应用程序上,按钮将在运行时创建。但当我按下按钮时,我有一个错误:
System.Exception:找不到方法GoToPage的目标。
在Caliburn.Micro.ActionMessage.Invoke(对象事件参数)
在Caliburn.Micro.TriggerAction`1.Execute处(对象发送器,对象参数)
在Microsoft.Xaml.Interactivity.Interaction.ExecuteActions(对象发送器、ActionCollection操作、对象参数)
在Microsoft.Xaml.Interactions.Core.EventTriggerBehavior.OneEvent(对象发送方,对象事件参数)
为什么??对于WP 8.0,此代码有效
谢谢 您必须在ActionMessage上指定
AssociatedObject
。在您的情况下,这是按钮
以下问题描述了详细信息:
此异常的另一个原因可能是 如果未注册viewmodel,也会发生@Max描述的异常:
_container = new WinRTContainer();
_container.RegisterWinRTServices();
_container.PerRequest<TestViewModel>(); // <-- without that line I got the same error
\u container=new WinRTContainer();
_container.RegisterWinRTServices();
_container.PerRequest();//嗨,提贝尔,谢谢你的回答。对于ActionMessage上的AssociatedObject,我在生成时出现以下错误:1-“成员“AssociatedObject”无法识别或无法访问。”和2-“在类型“ActionMessage”中未找到属性“AssociatedObject”。您好!你的解决方案有效!我之前的评论中描述的错误取决于VisualStudio,我认为,现在我所有的代码构建都没有任何问题。谢谢