C# 正在尝试传递列表<;对象>;从一页到另一页
嗨,我想通过我的应用程序中的页面传递参数。 它使用字符串和int。但是我想传递的是一个列表 我实际上在做什么: 主页:C# 正在尝试传递列表<;对象>;从一页到另一页,c#,windows-phone,C#,Windows Phone,嗨,我想通过我的应用程序中的页面传递参数。 它使用字符串和int。但是我想传递的是一个列表 我实际上在做什么: 主页: PhoneApplicationService.Current.State["file"] = file; NavigationService.Navigate( new Uri(string.Format("/gamepage.xaml"), UriKind.Relative)); 第二页: file = (Elements)PhoneApplicationServic
PhoneApplicationService.Current.State["file"] = file;
NavigationService.Navigate(
new Uri(string.Format("/gamepage.xaml"), UriKind.Relative));
第二页:
file = (Elements)PhoneApplicationService.Current.State["file"];
文件如下所示:元素文件
和元素:列表
我的文件是空的。你知道为什么吗 您需要越过
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;
}
}
public List SomeComplexProperty{get;set;}
受保护的覆盖无效OnNavigatedFrom(NavigationEventArgs e)
{
//NavigationEventArgs将返回“DestinationPage”
DestinationPage _page=e.内容作为DestinationPage;
如果(_page!=null)
{
_page.SomeComplexProperty=listObject;
}
}
[1] :你说的“NavigationEventArgs将返回“DestinationPage”是什么意思?我的意思是找不到“类型DestinationPage”,这是我不理解的,DestinationPage将是你导航到的新页面。在你的情况下,我认为它是“游戏页面”