我正在使用Microsoft Expression Blend 4 我有一个浏览器..,[XAML] ConnectionView“后面的空代码” <WebBrowser local:AttachedProperties.BrowserSource="{Binding Source}"> <i:Interaction.Triggers> <i:EventTrigger> <i:InvokeCommandAction Command="{Binding LoadedEvent}"/> </i:EventTrigger> <i:EventTrigger EventName="Navigated"> <i:InvokeCommandAction Command="{Binding NavigatedEvent}" CommandParameter="??????"/> </i:EventTrigger> </i:Interaction.Triggers> </WebBrowser> [C#] AttachedProperties类public static class AttachedProperties { public static readonly DependencyProperty BrowserSourceProperty = DependencyProperty . RegisterAttached ( "BrowserSource" , typeof ( string ) , typeof ( AttachedProperties ) , new UIPropertyMetadata ( null , BrowserSourcePropertyChanged ) ); public static string GetBrowserSource ( DependencyObject _DependencyObject ) { return ( string ) _DependencyObject . GetValue ( BrowserSourceProperty ); } public static void SetBrowserSource ( DependencyObject _DependencyObject , string Value ) { _DependencyObject . SetValue ( BrowserSourceProperty , Value ); } public static void BrowserSourcePropertyChanged ( DependencyObject _DependencyObject , DependencyPropertyChangedEventArgs _DependencyPropertyChangedEventArgs ) { WebBrowser _WebBrowser = _DependencyObject as WebBrowser; if ( _WebBrowser != null ) { string URL = _DependencyPropertyChangedEventArgs . NewValue as string; _WebBrowser . Source = URL != null ? new Uri ( URL ) : null; } } }最后:使用命令绑定工作正常,并显示MessageBoxes我的问题:如何在导航事件发生时将NavigationEventArgs作为命令参数传递?
3 回答
鸿蒙传说
TA贡献1865条经验 获得超7个赞
它不容易支持。这是一篇文章,内容涉及如何将EventArgs作为命令参数传递。
您可能希望研究使用MVVMLight - 它直接支持命令中的EventArgs; 你的情况看起来像这样:
<i:Interaction.Triggers>
<i:EventTrigger EventName="Navigated">
<cmd:EventToCommand Command="{Binding NavigatedEvent}"
PassEventArgsToCommand="True" />
</i:EventTrigger>
</i:Interaction.Triggers>
- 3 回答
- 0 关注
- 1068 浏览
添加回答
举报
0/150
提交
取消