سؤال

I am currently using the WinRTXamlToolkit's AlternativeFrame control to display multiple pages in a popup, for setting up the ability to post something to reddit. My current problem is that the navigate method for the AlternativeFrame does not appear to work.

Excerpt from RedditUploadDialog.xaml

<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>

Excerpt from 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));

The first call to Navigate (not above) DOES work, which loads a RUDSubPage1 control. The problem is, the second call to Navigate, as shown above, hangs when I make the call. It never returns, so the await remains stuck on it forever. RUDSubPage2 is very nearly empty in its xaml and code behind files, so nothing in it is interfering the the Navigate method. Any ideas why this isn't working?

Edit: Ok, I found the troublesome line in the WinRTXamlToolkit code.

    /// <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);
        }
    }

For some reason, the line above will always hang in my app after I try calling the Navigate method a second time. Anyone know why it might be doing this?

هل كانت مفيدة؟

المحلول

I decided to just comment out the troublesome line that I found in my original post, and now everything works. This isn't really a good solution, as I hate doing things like this to make things work, but I can't figure out why that line of code makes my program hang. Thanks for the help.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top