我有一个TabbedPage
并且我打算做的是将一个 json 流式传输ListView
到ContentPage
MainPage 下的一个。
据我所知,当翻译成 xaml 时,丢失的地方就出现了。
谁能帮我解决这个问题?
我的代码如下所示:
我的 C# 文件
void OnListViewItemSelected(object sender, SelectedItemChangedEventArgs eventInfo)
{
if (eventInfo.SelectedItem != null)
{
cityItem clickedCityName = (cityItem)eventInfo.SelectedItem;
System.Diagnostics.Debug.WriteLine(clickedCityName.cityAddress);
citiesListView.SelectedItem = null;
SingelCityPage pcity = new SingelCityPage ();
pcity.currentCity = clickedCityName;
//Looks like I am missing something here but I don't find any reference.
//or is in the XML that its missing the connection?
Navigation.PushAsync(pcity);
}
}
我的 Xaml
<ContentPage.Content>
<StackLayout>
<ListView x:Name="citiesListView">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.ContextActions>
<AbsoluteLayout Padding="10,10,10,10">
<Label Text="{Binding cityName}" AbsoluteLayout.LayoutBounds="0.0, 0.0, 0.75, 0.5" AbsoluteLayout.LayoutFlags="All" />
<Label Text="{Binding cityLocation}" AbsoluteLayout.LayoutBounds="0.0, 1.0, 0.75, 0.5" AbsoluteLayout.LayoutFlags="All" />
<Label Text="{Binding cityAdress}" AbsoluteLayout.LayoutBounds="1.0, 0.0, 0.5, 1.0" AbsoluteLayout.LayoutFlags="All" />
</AbsoluteLayout>
</ViewCell.ContextActions>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage.Content>