NavigationService.GetNavigationService 方法 ---NavigationService可以为null

前端之家收集整理的这篇文章主要介绍了NavigationService.GetNavigationService 方法 ---NavigationService可以为null前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

NavigationService.GetNavigationService 方法

更新:2007 年 11 月

获取对导航器的 NavigationService 的引用,该导航器的内容中包含指定的 DependencyObject

命名空间: System.Windows.Navigation
程序集: PresentationFramework(在 PresentationFramework.dll 中)

语法

public static NavigationService GetNavigationService(
	DependencyObject dependencyObject
)
@H_404_88@ 
      
J#
public static NavigationService GetNavigationService(
	DependencyObject dependencyObject
)
@H_404_88@ 
      
不能在 XAML 中使用方法。
@H_404_88@ 
      

参数

dependencyObject
类型: System.Windows.DependencyObject

由导航器承载的内容中的 DependencyObject

返回值

类型: System.Windows.Navigation.NavigationService

对导航器(该导航器的内容中包含指定的 DependencyObject)的 NavigationService 的引用在某些情况下可以为 null(请参见“备注”)。

异常

异常 条件
ArgumentNullException

dependencyObject 参数为 null

备注

导航器具有一个可处理内容导航的 NavigationService。WPF 具有两种导航器:NavigationWindowFrame。为了处理导航请求和管理导航生存期,导航器将使用 WPF 导航服务,该服务作为 NavigationService 类实现。由导航器承载的内容可以通过调用 GetNavigationService 方法获取对导航器的 NavigationService 的引用。

dependencyObject 符合以下条件时,GetNavigationService 将返回 null

WPF 提供两种快捷方式来获取NavigationService 的引用:

示例

下面的示例演示 UserControl 如何通过调用 GetNavigationService 检索导航服务。

void getNavigationServiceButton_Click(object sender,RoutedEventArgs e) {
    // Retrieve first navigation service up the content tree
    NavigationService svc = NavigationService.GetNavigationService(this.getNavigationServiceButton);
    if (svc != null)
    {
        // Use navigation service


...


    }
}

@H_404_88@ 
       
原文链接:https://www.f2er.com/vb/261569.html

猜你在找的VB相关文章