0

Hi I'd like to pass arguments through pages in my application. its working with string and int. But what i want to pass is a list What I'm actually doing :

MainPage :

PhoneApplicationService.Current.State["file"] = file;
NavigationService.Navigate(
  new Uri(string.Format("/gamepage.xaml"), UriKind.Relative));

SecondPage :

file = (Elements)PhoneApplicationService.Current.State["file"];

File looks like that : Elements file

And Elements : list<Element>

Arriving my file is empty Oo. Do you know why ?


You will need to over ride the OnNavigatedFrom [method][1]

On DestinationPage, create the property of your complex type

public List<string> SomeComplexProperty {get;set;}

protected override void OnNavigatedFrom(NavigationEventArgs e)
{
  // NavigationEventArgs will return  "DestinationPage"
    DestinationPage _page = e.Content as DestinationPage;
    if (_page!= null)
    {

        _page.SomeComplexProperty = listObject;
    }
}

[1]:

4

1 回答 1

0

您将需要超越OnNavigatedFrom[method][1]

DestinationPage,创建复杂类型的属性

public List<string> SomeComplexProperty {get;set;}

protected override void OnNavigatedFrom(NavigationEventArgs e)
{
  // NavigationEventArgs will return  "DestinationPage"
    DestinationPage _page = e.Content as DestinationPage;
    if (_page!= null)
    {

        _page.SomeComplexProperty = listObject;
    }
}

[1]:

于 2013-10-03T14:45:37.023 回答