我想在我的ViewModel的DelegateCommand中包含“发送者”对象。
<WebBrowser>
<i:Interaction.Triggers>
<i:EventTrigger EventName="Navigated">
<prism:InvokeCommandAction
Command="{Binding NavigatedCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</WebBrowser>
private DelegateCommand<NavigationEventArgs> _onNavigated;
public DelegateCommand<NavigationEventArgs> NavigatedCommand => _onNavigated ?? (_onNavigated = new DelegateCommand<NavigationEventArgs>(OnNavigated, (e) => true));
private void OnNavigated(NavigationEventArgs e)
{
//TODO add code to access the WebBrowser.Document property
}
这不起作用:
private DelegateCommand<WebBrowser, NavigationEventArgs> _onNavigated;
什么是委托命令?
答案 0 :(得分:0)
您要使用-- some comment
-- comment
*blank lines*
*various SET statements*
*SELECT statements*
INSERT [...]
-- some comments
*more blank lines*
而不是i:InvokeCommandAction
。
我不知道,为什么棱镜变体不适用于prism:InvokeCommandAction
,但互动性却不能...
查看:
CommandParameter
查看模型:
<WebBrowser>
<i:Interaction.Triggers>
<i:EventTrigger EventName="Navigated">
<i:InvokeCommandAction Command="{Binding NavigatedCommand}"
CommandParameter="{Binding Path=Document, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type WebBrowser}}}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</WebBrowser>