As can be seen in the SimpleMDI Caliburn Micro project there are some conventions that bind the selectionEvent in tabControls to the ActivateItem in a Conductor. I can't really see any mention of what this event might be.

However when you have a control that doesn't fullfill these convention I'm lost on how to manage them myself.

I have a Telerik RadTreeView that I want to manage with a conductor to be able to load on demand the childs of nodes (via WCF call).

Here is where I am at:

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

Passing $dataContext is wrong because that way he passes the Conductor itself, $SelectedItem returns null.

So my rather simple question is threefold.

1) If RadTreeView is a Selecetor why doesn't the basic CM convention work with it,

2) What event should I use to call ActiveItem

3) What could I pass in.

有帮助吗?

解决方案

This might help understand the different approaches to doing treeviews and mvvm.

I was using the RadTreeView also and I ended up sending the events to the ViewModel that hosted the Items collection of TreeViewItemViewModel. When an action/event, for example, Edit, was sent to the MainViewModel, I had a method like:

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

            treeViewItemViewModel.EndEdit();
        }

So this worked at any level in the tree and also worked for having different behaviors, checking to see if the interface for different things was implemented.

xaml for the RadTreeView

 <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)]"/>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top