[英]Caliburn Micro “No target found for method Event…” for TreeView SelectedItemChanged event
I am having an issue with the following (just showing snippets of my code):我遇到以下问题(仅显示我的代码片段):
XAML: XAML:
<TreeView Name="TypeTree" ItemsSource="{Binding TypeTreeItems}"
cal:Message.Attach="[Event SelectedItemChanged] = Action[SetSelectedType($this.SelectedItem)]">
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Path=mChildren}">
<TextBlock Text="{Binding Path=mNodeName}"/>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
ViewModel:视图模型:
public void SetSelectedType(TreeNode item)
{
MessageBox.Show("Here");
_selectedType = item;
}
System.Exception: 'No target found for method Event SelectedItemChanged = ActionSetSelectedSource.' System.Exception:'没有找到方法 Event SelectedItemChanged = ActionSetSelectedSource 的目标。
I'm still new to MVVM and Caliburn Micro so am not sure what is causing the issue.我对 MVVM 和 Caliburn Micro 还是新手,所以我不确定是什么导致了这个问题。 Anyone able to provide a bit of guidance as to where I've gone wrong?
任何人都可以提供一些关于我哪里出错的指导? Happy to provide more snippets if it helps!
如果有帮助,很高兴提供更多片段!
Thanks!谢谢!
The syntax is wrong.语法错误。 Try this:
尝试这个:
cal:Message.Attach="[Event SelectedItemChanged] = [Action SetSelectedType($this.SelectedItem)]"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.