locked
Navigate Causes Crash From Navigated Page

    Question

  • Using VS2013 Express For Windows

    I created a new app using the 'SplitPage' template.

    Navigation works great, until I add a navigation from within the split page:

            private void itemListView_ItemClick(object sender, ItemClickEventArgs e)
            {

                try
                {
                    //...etc.
                    this.Frame.Navigate(typeof(MyPage), e);
                }
                catch (Exception ex)
                {
                    Debug.Assert(false, ex.Message);
                }
            }


    The app will crash (suspensionmanager) once I hit F4: no crash if I don't navigate

    What am I doing wrong?

    Wednesday, May 14, 2014 10:29 PM

Answers

  • Hi,

    That was the issue - I was passing the clicked item as per your example.  I found the error on MSDN in the documentation for the Frame and it stated that you must pass a 'known' type (i.e. string, bool, etc) or you will get the error.  If I want to pass the clicked item, I first have to make it serializable and add it to the knowtypes collection.  The easiest thing to do was add a string 'Key' to my class and I pass that; which works just fine.

    Thursday, May 15, 2014 1:50 PM

All replies

  • Hi,

    There is not enough information to detect why the problem occur. You should upload your project to skyDrive so that we can test it.

    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, May 15, 2014 2:16 AM
  • I figured out what the issue was. I wasn't passing a known type as the parameter, but rather the class (clicked item).  The error was:

    WinRT information: GetNavigationState doesn't support serialization of a parameter type which was passed to Frame.Navigate.

    I now need to figure out some logic I can put into a string that will tell my page what item was clicked ;)

    Thursday, May 15, 2014 11:20 AM
  • Hi,

    what string do you want to pass to the Mypage? You can get the click item in the itemListView_ItemClick event. And if you want to pass the object of click-item to Mypage, you can code like below:

    void itemListView_ItemClick(object sender, ItemClickEventArgs e) { var item = e.ClickedItem;//get the clicked item

    this.Frame.Navigate(typeof(MyPage), item); }

    If you want to pass a property in the click-item you can code like below:

      void itemListView_ItemClick(object sender, ItemClickEventArgs e)
            {
                var itemId = ((SampleDataItem)e.ClickedItem).UniqueId;
                this.Frame.Navigate(typeof(MyPage), itemId);
            }

    Suppose the Listview item bind to the SampleDataItem class and the class has a property of UniqueId.

    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, May 15, 2014 12:52 PM
  • Hi,

    That was the issue - I was passing the clicked item as per your example.  I found the error on MSDN in the documentation for the Frame and it stated that you must pass a 'known' type (i.e. string, bool, etc) or you will get the error.  If I want to pass the clicked item, I first have to make it serializable and add it to the knowtypes collection.  The easiest thing to do was add a string 'Key' to my class and I pass that; which works just fine.

    Thursday, May 15, 2014 1:50 PM