如何实现LightSwitch外壳扩展,在启动时显示默认屏幕

本文关键字:启动 显示 屏幕 默认 扩展 外壳 何实现 实现 LightSwitch | 更新日期: 2023-09-27 18:21:17

我正在为LightSwitch应用程序实现一个shell扩展,查看MSDN上的示例。

我已经查看了IServiceProxy中的每个对象,但找不到任何方法在启动时显示默认屏幕。

默认shell可以在启动时显示默认屏幕,但MSDN上的示例没有。有办法做到这一点吗?

如何实现LightSwitch外壳扩展,在启动时显示默认屏幕

以下是我在Shell中使用的代码:

        void MinimalShell_Loaded(object sender, RoutedEventArgs e)
    {
        // Open the Default Screen
        // The navigation view model will only return those links that can be executed.  In order
        // to do that, it will call the CanExecute() method on the links - which is an
        // asynchronous operation. 
        // "prime" the view model by asking for the links.  If we don't do this, the first
        // command entered in the shell will not work (all commands after that will work).
        this.ServiceProxy.NavigationViewModel.NavigationItems.Count();
        // Getthe Tasks group as a INavigationItem
        INavigationItem objINavigationItem = 
            (this.ServiceProxy.NavigationViewModel.DefaultItem as INavigationItem);
        // Cast the INavigationItem to a INavigationGroup
        INavigationGroup objINavigationGroup = (INavigationGroup)objINavigationItem;
        if (objINavigationGroup.DefaultChild is INavigationScreen)
        {
            // Get the Default Screen
            INavigationScreen objINavigationScreen = (INavigationScreen)objINavigationGroup.DefaultChild;
            // Set DefaultScreenName
            DefaultScreenName = objINavigationScreen.DisplayName;
            // The screen may not be ready yet
            // Wait until the screen can be opened
            while (!objINavigationScreen.ExecutableObject.CanExecuteAsync)
            {
                // Do nothing until the screen can be opened
            }
            // Open the Default Screen
            objINavigationScreen.ExecutableObject.ExecuteAsync();
        }
    }