Search code examples
wpfdatacontextcaliburn.microevent-bubblingvisual-tree

Caliburn.Micro message bubbling skipping a control


I've got a hierarchical collection and I lazy load the lowest level because of it's size.

The action I'm trying to activate is on the CollectionHolderManager but it seems that the bubbling skips that visual layer for some reason.

<ItemsControl DataContext="{Binding Path=CollectionHolderManager}"
                      ItemsSource="{Binding Path=CollectionTopLevel}">
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <telerik:RadToolBar cal:Bind.Model="{Binding}">

                <TextBlock x:Name="Name" />

                <ItemsControl ItemsSource="{Binding Path=CollectionMiddleLevel}">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>

                            <telerik:RadDropDownButton cal:Bind.Model="{Binding}"
                                                               Content="{Binding Path=Name}"
                                                               cal:Message.Attach="[Event DropDownOpened] = [Action GetLowestLevel($dataContext)]">
                                <telerik:RadDropDownButton.DropDownContent>
                                    <telerik:RadListBox SelectionMode="Multiple"
                                                                ItemsSource="{Binding Path=CollectionLowestLevel}">
                                        <telerik:RadListBox.ItemTemplate>
                                            <DataTemplate>

                                                <!-- some template -->

                                            </DataTemplate>
                                        </telerik:RadListBox.ItemTemplate>

                                    </telerik:RadListBox>
                                </telerik:RadDropDownButton.DropDownContent>
                            </telerik:RadDropDownButton>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </telerik:RadToolBar>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>

So if I have the action on the TopLevelCollection it get's called.

If I have it on the ViewModel that owns CollectionHolderManager it get's called, but not when it's on the CollectionHodlerManager itself. Why is it skipping over that?


Solution

  • Such a simple thing I can't believe I missed it.

    <ItemsControl cal:Bind.Model="{Binding Path=CollectionHolderManager}"
                  ItemsSource="{Binding Path=CollectionTopLevel}">
    

    Bind.Model instead of DataContext.