我有一个PdfViewerView.xaml(UserControl
),其中包含名为" PdfViewerCtrl"的控件。
现在我得到了一个带有上下文菜单的ListBox
,如果用户点击上下文菜单,则会出现一个带有多个绑定触发器的事件:
<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
(我在开头提到)作为参数传递,但它总是DependencyProperty.UnsetValue
。
正如您所看到的,我尝试了两种绑定PdfViewerCtrl
的方式,但两种方式都无法正常工作。
答案 0 :(得分:1)
尝试使用Tag
标记扩展名将PdfViewerCtrl
属性设置为x:Reference
,然后绑定到Tag
的{{1}}属性:
ContextMenu