2012-01-25 1 views
0

Я реализую расширение оболочки для приложений LightSwitch, глядя на образец на MSDN.Как реализовать расширение оболочки LightSwitch, отображающее экран по умолчанию при запуске?

Я просмотрел все объекты в IServiceProxy, но не смог найти способ отображения экрана по умолчанию при запуске.

По умолчанию оболочка может показывать экран по умолчанию при запуске, но образец на MSDN - нет. Есть какой-либо способ сделать это?

ответ

1

Вот код, который я использовал в своей 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(); 
     } 
    } 
+0

отлично работает! Спасибо! –

 Смежные вопросы

  • Нет связанных вопросов^_^