Caliburn Micro "No target found for method Event..." 用于 TreeView SelectedItemChanged 事件
Caliburn Micro "No target found for method Event..." for TreeView SelectedItemChanged event
我遇到以下问题(仅显示我的代码片段):
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>
视图模型:
public void SetSelectedType(TreeNode item)
{
MessageBox.Show("Here");
_selectedType = item;
}
System.Exception: 'No target found for method Event SelectedItemChanged = ActionSetSelectedSource.'
我还是 MVVM 和 Caliburn Micro 的新手,所以我不确定是什么导致了这个问题。任何人都能够提供一些关于我哪里出错的指导?如果有帮助,很高兴提供更多片段!
谢谢!
语法错误。试试这个:
cal:Message.Attach="[Event SelectedItemChanged] = [Action SetSelectedType($this.SelectedItem)]"
我遇到以下问题(仅显示我的代码片段):
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>
视图模型:
public void SetSelectedType(TreeNode item)
{
MessageBox.Show("Here");
_selectedType = item;
}
System.Exception: 'No target found for method Event SelectedItemChanged = ActionSetSelectedSource.'
我还是 MVVM 和 Caliburn Micro 的新手,所以我不确定是什么导致了这个问题。任何人都能够提供一些关于我哪里出错的指导?如果有帮助,很高兴提供更多片段!
谢谢!
语法错误。试试这个:
cal:Message.Attach="[Event SelectedItemChanged] = [Action SetSelectedType($this.SelectedItem)]"