为什么当我更改页面时你关闭了应用程序?
Why do you close the app when I change the page?
我有两个列表<>。
List<Musei> ListMusei;
List<Regioni> reg;
对象 "Musei" 有 属性 "Paese",而对象 "Regioni" 有 属性 "NomeProvincia"。
List "reg" 被插入到 ListView 中,当按下一个项目时,调用此方法:
private void Listviewcitt_ItemClick(object sender, ItemClickEventArgs e)
{
var result = ((Regioni)e.ClickedItem).NomeProvincia.ToString();
var filtro = ListMusei.Where(x => x.Paese.Equals(result));
try
{
Frame.Navigate(typeof(PageAroundMe), filtro);
}
catch(Exception)
{
}
}
我总是关闭的应用程序。我以为"AroundMe"里面有问题,然后把代码贴在这里:
在 Page AroundMe 中,我这样做:
List<Musei> ListMusei;
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
ListMusei = (List<Musei>) e.Parameter;
List<Pushpin> push = new List<Pushpin>();
foreach (Musei SingoloMuseo in ListMusei)
{
Pushpin Pushpin pushpin1 = new ();
GeoPoint posizioneP;
try
{
MapLocationFinderResult result = await MapLocationFinder.FindLocationsAsync (SingoloMuseo.Indirizzo, null);
posizioneP result.Locations.FirstOrDefault = ().Point;
pushpin1.Name = SingoloMuseo.NomeMuseo;
pushpin1.Location = posizioneP;
push.Add (pushpin1);
}
catch (Exception)
{
continue;
}
}
问题出在哪里?我什至不知道我将在哪里关闭
你可以像这样传递参数
Frame.Navigate(typeof(PageAroundMe), filtro.ToList());
由于您试图将 IEnumerable 类型转换为 List,因此发生无效转换异常。
我有两个列表<>。
List<Musei> ListMusei;
List<Regioni> reg;
对象 "Musei" 有 属性 "Paese",而对象 "Regioni" 有 属性 "NomeProvincia"。 List "reg" 被插入到 ListView 中,当按下一个项目时,调用此方法:
private void Listviewcitt_ItemClick(object sender, ItemClickEventArgs e)
{
var result = ((Regioni)e.ClickedItem).NomeProvincia.ToString();
var filtro = ListMusei.Where(x => x.Paese.Equals(result));
try
{
Frame.Navigate(typeof(PageAroundMe), filtro);
}
catch(Exception)
{
}
}
我总是关闭的应用程序。我以为"AroundMe"里面有问题,然后把代码贴在这里: 在 Page AroundMe 中,我这样做:
List<Musei> ListMusei;
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
ListMusei = (List<Musei>) e.Parameter;
List<Pushpin> push = new List<Pushpin>();
foreach (Musei SingoloMuseo in ListMusei)
{
Pushpin Pushpin pushpin1 = new ();
GeoPoint posizioneP;
try
{
MapLocationFinderResult result = await MapLocationFinder.FindLocationsAsync (SingoloMuseo.Indirizzo, null);
posizioneP result.Locations.FirstOrDefault = ().Point;
pushpin1.Name = SingoloMuseo.NomeMuseo;
pushpin1.Location = posizioneP;
push.Add (pushpin1);
}
catch (Exception)
{
continue;
}
}
问题出在哪里?我什至不知道我将在哪里关闭
你可以像这样传递参数
Frame.Navigate(typeof(PageAroundMe), filtro.ToList());
由于您试图将 IEnumerable 类型转换为 List,因此发生无效转换异常。