Wpf 多重绑定未设置值

Wpf 多重绑定未设置值,wpf,xaml,mvvm,binding,multibinding,Wpf,Xaml,Mvvm,Binding,Multibinding,我有一个PdfViewerView.xaml用户控件,其中包含一个名为PdfViewerCtrl的控件。 现在我得到了一个带有上下文菜单的列表框,如果用户单击上下文菜单项,则会出现一个带有多绑定触发器的事件: <ContextMenu> <MenuItem Header="Löschen"/> <i:Interaction.Triggers> <i:EventTri

我有一个PdfViewerView.xaml用户控件,其中包含一个名为PdfViewerCtrl的控件。 现在我得到了一个带有上下文菜单的列表框,如果用户单击上下文菜单项,则会出现一个带有多绑定触发器的事件:

<ContextMenu>
              <MenuItem Header="Löschen"/>
              <i:Interaction.Triggers>
                 <i:EventTrigger
                                    EventName="PreviewMouseDown">
                    <i:InvokeCommandAction
                                        Command="{Binding DeleteAnnotationCmd}">
                       <i:InvokeCommandAction.CommandParameter>
                          <MultiBinding Converter="{StaticResource MultiBindingConv}">
                             <Binding ElementName="PdfUserCtrl" Path="PdfViewerCtrl" />
                             <Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}" Path="PdfViewerCtrl" />
                          </MultiBinding>
                       </i:InvokeCommandAction.CommandParameter>
                    </i:InvokeCommandAction>
                 </i:EventTrigger>
              </i:Interaction.Triggers>
           </ContextMenu>
我试图传递我在开始时提到的PdfViewerCtrl作为参数,但它始终是dependencProperty.unset值

如您所见,我尝试了两种绑定到PdfViewerCtrl的方法,但都不起作用。

尝试使用x:Reference标记扩展将标记属性设置为PdfViewerCtrl,然后绑定到ContextMenu的标记属性:


非常感谢你!!还有一个问题,也许你也能帮我。我还试图将列表框传递给ContextMenu的父级。最聪明的方法是什么?如果你有其他问题,请问一个新问题。如果可以的话,我很乐意帮助你。问题是因为ContextMenu是一个弹出窗口。它与onwer有不同的名称范围,也不是onwer的可视树的一部分。因此ElementName和RelativeSource都无法解析源代码。您知道如何传递contextmenu的所有者的解决方案吗?它的listboxContextMenu.PlacementTarget在打开后应包含所有者元素。你可以试试。非常感谢你!
<ContextMenu Tag="{x:Reference PdfViewerCtrl}">
    <MenuItem Header="Löschen"/>
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="PreviewMouseDown">
            <i:InvokeCommandAction Command="{Binding DeleteAnnotationCmd}">
                <i:InvokeCommandAction.CommandParameter>
                    <MultiBinding Converter="{StaticResource MultiBindingConv}">
                        <Binding RelativeSource="{RelativeSource AncestorType=ContextMenu}" Path="Tag" />
                    </MultiBinding>
                </i:InvokeCommandAction.CommandParameter>
            </i:InvokeCommandAction>
        </i:EventTrigger>
    </i:Interaction.Triggers>
</ContextMenu>