2016-12-14 1 views
0

Extended.xaml 화면에서 다른 화면 Main.xaml로 이동하려고합니다. 하지만 문제는 페이지가 다른 페이지로 이동하지 못하는 것입니다. 그것을 성취하는 방법? 어떤 도움을 주시면 감사하겠습니다.시도 확장 시작 화면에서 uwp의 다른 화면으로 이동

XAML 코드 :

<Grid x:Name="lcol"> 
    <Grid.Background> 
     <ImageBrush Stretch="Fill" 
        ImageSource="ms-appx:///Assets/Home/home_android.jpg" /> 
    </Grid.Background> 
    <RelativePanel Grid.Row="0"> 
    <Image x:Name="extendedSplashImage" Source="/Assets/Home/home_android.jpg"      
      Stretch="Uniform" Height="385" Width="690" 
      RelativePanel.AlignHorizontalCenterWithPanel="True" 
      RelativePanel.AlignLeftWithPanel="True" 
      RelativePanel.AlignRightWithPanel="True"/> 
    </RelativePanel> 
</Grid> 

고사 코드 : 당신은 App.xaml.cs.의 자세한 내용을 표시 할 수 있습니다

public sealed partial class ExtendedSplash : Page 
{ 
    internal Rect splashImageRect; // Rect to store splash screen image coordinates. 
    private SplashScreen splash; // Variable to hold the splash screen object. 
    internal bool dismissed = false; // Variable to track splash screen dismissal status. 
    internal Frame rootFrame; 

    public ExtendedSplash(SplashScreen splashscreen, bool loadState) 
    { 
     InitializeComponent() 
     try 
     { 
      var bounds = ApplicationView.GetForCurrentView().VisibleBounds; 
     } 
     catch (Exception ex) 
     { 
      Log.print(ex.StackTrace); 
     } 
     // Listen for window resize events to reposition the extended splash screen image accordingly. 
     // This is important to ensure that the extended splash screen is formatted properly in response to snapping, unsnapping, rotation, etc... 
     // Window.Current.SizeChanged += new WindowSizeChangedEventHandler(ExtendedSplash_OnResize); 

     splash = splashscreen; 

     if (splash != null) 
     { 
      // Register an event handler to be executed when the splash screen has been dismissed. 
      splash.Dismissed += new TypedEventHandler<SplashScreen, Object>(DismissedEventHandler); 
      // Create a Frame to act as the navigation context 
      rootFrame = new Frame(); 
      DismissExtendedSplash(); 
     } 
    } 
    void PositionImage() 
    { 
     extendedSplashImage.SetValue(Canvas.LeftProperty, splashImageRect.X); 
     extendedSplashImage.SetValue(Canvas.TopProperty, splashImageRect.Y); 
     extendedSplashImage.Height = splashImageRect.Height; 
     extendedSplashImage.Width = splashImageRect.Width; 

    } 
    void ExtendedSplash_OnResize(Object sender, WindowSizeChangedEventArgs e) 
    { 
     // Safely update the extended splash screen image coordinates. This function will be fired in response to snapping, unsnapping, rotation, etc... 
     if (splash != null) 
     { 
      // Update the coordinates of the splash screen image. 
      splashImageRect = splash.ImageLocation; 
      PositionImage(); 
     } 
    } 
    // Include code to be executed when the system has transitioned from the splash screen to the extended splash screen (application's first view). 
    void DismissedEventHandler(SplashScreen sender, object e) 
    { 
     dismissed = true; 
     // Complete app setup operations here... 
    } 
    private void DismissExtendedSplash() 
    { 
     rootFrame.Navigate(typeof(MainPage)); 
     // Place the frame in the current Window 
     Window.Current.Content = rootFrame; 
    } 
} 

답변

0

난 당신의 코드는 다음과

protected override void OnLaunched(LaunchActivatedEventArgs e) 
{ 
    if (e.PreviousExecutionState != ApplicationExecutionState.Running) 
    { 
     bool loadState = (e.PreviousExecutionState == ApplicationExecutionState.Terminated); 
     ExtendedSplash extendedSplash = new ExtendedSplash(e.SplashScreen, loadState); 
     Window.Current.Content = extendedSplash; 
    } 

    Window.Current.Activate(); 
} 

귀하의 ExtendedSplash 코드와 같은 공식 간단하게 작성한다고 가정

public ExtendedSplash(SplashScreen splashscreen, bool loadState) 
{ 
    InitializeComponent() 
    try 
    { 
     var bounds = ApplicationView.GetForCurrentView().VisibleBounds; 
    } 
    catch (Exception ex) 
    { 
     Log.print(ex.StackTrace); 
    } 

    splash = splashscreen; 

    if (splash != null) 
    { 
     // Register an event handler to be executed when the splash screen has been dismissed. 
     splash.Dismissed += new TypedEventHandler<SplashScreen, Object>(DismissedEventHandler); 
     // Create a Frame to act as the navigation context 
     rootFrame = new Frame(); 
     DismissExtendedSplash(); 
    } 
} 

당신은 완성 된 초기화 extendedSplash 전에 방법 DismissExtendedSplash()을 실행. 그래서 Window.Current.Conten이 MainPage이고, Window.Current.Content = extendedSplash을 excuted하면 MainPageextendedSplash으로 바뀝니다.

관련 문제