【问题标题】:Caliburn.Micro message bubbling skipping a controlCaliburn.Micro 消息冒泡跳过控件
【发布时间】:2012-08-23 15:49:53
【问题描述】:

我有一个分层集合,由于它的大小,我延迟加载最低级别。

我试图激活的操作是在 CollectionHolderManager 上,但似乎冒泡由于某种原因跳过了该可视层。

<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>

因此,如果我对 TopLevelCollection 执行操作,就会调用它。

如果我在拥有 CollectionHolderManager 的 ViewModel 上拥有它,它会被调用,但在 CollectionHodlerManager 本身上时不会。为什么要跳过它?

【问题讨论】:

    标签: wpf datacontext caliburn.micro event-bubbling visual-tree


    【解决方案1】:

    这么简单的事情我简直不敢相信我错过了。

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

    Bind.Model 而不是 DataContext。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-07-14
      • 1970-01-01
      • 2011-10-05
      • 2013-09-20
      • 1970-01-01
      • 2012-04-25
      • 1970-01-01
      相关资源
      最近更新 更多