2014-04-04 50 views
0

我目前使用WinRTXamlToolkit的AlternativeFrame控件在彈出框中顯示多個頁面,以設置將某些內容發佈到reddit的能力。我目前的問題是AlternativeFrame的導航方法似乎不起作用。從RedditUploadDialog.xamlWindows運行時WinRTXamlToolkit AlternativeFrame Navigate方法不起作用(掛起)

<ScrollViewer HorizontalAlignment="Left" Margin="10,130,0,0" VerticalAlignment="Top" Width="480" Height="310" VerticalScrollBarVisibility="Hidden"> 
      <Controls:AlternativeFrame x:Name="scrollingFrame" extensions:FrameworkElementExtensions.ClipToBounds="True"> 
       <Controls:AlternativeFrame.PageTransition> 
        <Controls:PushTransition ForwardDirection="Random" BackwardDirection="Random" /> 
       </Controls:AlternativeFrame.PageTransition> 
      </Controls:AlternativeFrame> 
     </ScrollViewer> 

摘錄

摘自RedditUploadDialog.xaml.cs

/*"scrollingFrame" is an AlternativeFrame control inside of a scrollviewer. RUDSubPage2 is an */AlternativePage control. RUDSubPage2's code page does not have any code in it except for the InitializeComponents method in the 
await this.scrollingFrame.Navigate(typeof(RUDSubPage2)); 

第一次調用導航(不高於)不工作,它加載一個RUDSubPage1控制。問題是,如上所示,第二次調用Navigate時,會在我打電話時掛起。它永遠不會回來,所以等待會永遠停留在它上面。 RUDSubPage2在它的xaml和代碼隱藏文件中幾乎是空的,所以沒有任何內容干擾Navigate方法。任何想法爲什麼這不起作用?

編輯:好的,我在WinRTXamlToolkit代碼中找到了麻煩的一行。

/// <summary> 
    /// Contains extension methods to wait for FrameworkElement events. 
    /// </summary> 
    public static class FrameworkElementExtensions 
    { 
     /// <summary> 
     /// Waits for the element to load (construct and add to the main object tree). 
     /// </summary> 
     public static async Task WaitForLoadedAsync(this FrameworkElement frameworkElement) 
     { 
      if (frameworkElement.IsInVisualTree()) 
       return; 

      //This line, right here, is the one that keeps hanging. This method is called from within the Navigate method of the AlternativeFrame control. Also, frameworkElement here is the AlternativeFrame while the code is running. 
      await EventAsync.FromRoutedEvent(
       eh => frameworkElement.Loaded += eh, 
       eh => frameworkElement.Loaded -= eh); 
     } 
    } 

出於某種原因,該線之上會一直在我的應用程序掛我嘗試調用導航方法的第二時間之後。任何人都知道爲什麼它會這樣做?

+0

在'RedditUploadDialog.xaml.cs'中你在調用'Navigate'函數? –

+0

你能分享一個repro項目嗎?您是否嘗試過使用源代碼而不是NuGet包進行調試? –

+0

導航功能在RedditUploadDialog.xaml.cs文件的按鈕按下事件中調用。我會嘗試使用源代碼並構建它而不是Nuget包,因此我可以通過調試器正確地完成它。我真的沒有想到這樣做。 –

回答

1

我決定只評論我在原始文章中找到的麻煩行,現在一切正常。這不是一個很好的解決方案,因爲我討厭這樣做,使事情發揮作用,但我無法弄清楚爲什麼這行代碼會讓我的程序掛起。謝謝您的幫助。