Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf Caliburn Micro:如何将ActivateItem绑定到导体中的selectionEvents_Wpf_Caliburn.micro_Rad Controls_Convention Over Configur - Fatal编程技术网

Wpf Caliburn Micro:如何将ActivateItem绑定到导体中的selectionEvents

Wpf Caliburn Micro:如何将ActivateItem绑定到导体中的selectionEvents,wpf,caliburn.micro,rad-controls,convention-over-configur,Wpf,Caliburn.micro,Rad Controls,Convention Over Configur,从SimpleMDI Caliburn Micro项目中可以看出,有一些约定将tabControls中的selectionEvent绑定到导体中的ActivateItem。我真的看不出这件事可能是什么 然而,当你有一个不能满足这些惯例的控制时,我就不知道如何自己管理它们了 我有一个Telerik RadTreeView,我想用一个导体来管理它,以便能够按需加载节点的子节点(通过WCF调用) 以下是我的位置: <telerik:RadTreeView x:Name="Items"

从SimpleMDI Caliburn Micro项目中可以看出,有一些约定将tabControls中的selectionEvent绑定到导体中的ActivateItem。我真的看不出这件事可能是什么

然而,当你有一个不能满足这些惯例的控制时,我就不知道如何自己管理它们了

我有一个Telerik RadTreeView,我想用一个导体来管理它,以便能够按需加载节点的子节点(通过WCF调用)

以下是我的位置:

<telerik:RadTreeView x:Name="Items"
                     cal:Message.Attach="[Event Selected] = [ActivateItem($dataContext)]"  />

传递$dataContext是错误的,因为这样他就传递了导体本身,$SelectedItem返回null

所以我相当简单的问题有三个

1) 如果RadTreeView是一个Selector,那么为什么基本CM约定不能与之配合使用

2) 我应该使用什么事件调用ActiveItem

3) 我可以传递什么。

可能有助于理解使用TreeView和mvvm的不同方法

我也在使用RadTreeView,最后我将事件发送到承载
项目
集合
TreeViewItemModel
的ViewModel。当一个动作/事件(例如Edit)被发送到MainViewModel时,我有一个类似以下的方法:

 public void Edited(object sender, RadTreeViewItemEditedEventArgs e)
        {
            var treeViewItemViewModel = e.NewValue as IEditable;
            if (treeViewItemViewModel == null) return;

            treeViewItemViewModel.EndEdit();
        }
因此,这在树中的任何级别都起作用,也适用于具有不同的行为,检查是否实现了不同事物的接口

RadTreeView的xaml

 <telerik:RadTreeView x:Name="MyTree"
                                     Grid.Row="1"
                                     Margin="0,20,0,0"
                                     VerticalAlignment="Stretch"
                                     FontSize="16"
                                     FontFamily="{StaticResource MainFontFamily}"
                                     ItemsSource="{Binding Children, Mode=TwoWay}"
                                     ItemTemplate="{StaticResource HierarchicalDataTemplate}"
                                     ItemEditTemplateSelector="{StaticResource ItemEditTemplateSelector}"
                                     ItemEditTemplate="{x:Null}"
                                     IsLoadOnDemandEnabled="True"
                                     IsEditable="True"
                                     IsDragDropEnabled="True"
                                     DropExpandDelay="00:00:01"
                                     telerik:TextSearch.TextPath="ItemId"
                                     PathSeparator="|"
                                     cal:Message.Attach="
                                    [Event LoadOnDemand] = [Action LoadOnDemand($eventArgs)];
                                    [Event PreviewDragStarted] = [Action PreviewDragStarted($source,$eventArgs)];
                                    [Event PreviewDragEnded] = [Action PreviewDragEnded($source,$eventArgs)];
                                    [Event DragEnded] = [Action DragEnded($source,$eventArgs)];
                                    [Event Edited] = [Action Edited($source,$eventArgs)];
                                    [Event EditCanceled] = [Action EditCanceled($source,$eventArgs)]"/>


您正在显示分层数据吗?我实际上已经改变了它的工作方式。是的,我想显示层次结构,但它会实现IActivate。问题在于将treeview中的事件与导体的激活逻辑相连接。我不知道如何将所选项目作为参数传递。Caliburn.Micro应该可以帮助您避免像这样的混乱。因此,您可以创建一个普通方法,并将某些内容作为参数传递给。参数应该是我刚刚选择的项目,但我希望我可以在cal:Message.AttachI中这样说,我正在使用Message.Attach[事件编辑]=[操作编辑($source$eventArgs)];`我编辑以显示树视图的xaml。如果您还有任何问题,请告诉我,我可以提供更好的示例。