0
我知道這個問題聽起來微不足道,但由於我是windows phone開發新手,我似乎無法理解如何在我的場景中執行此操作。如何顯示網格中的對象列表
我有一個
List<Forecast> forecasts
,我想連接到我的WeatherInfoBar
<Grid x:Name="WeatherInfoLowBar" Height="300" VerticalAlignment="Bottom">
<StackPanel Grid.Column="1" VerticalAlignment="Top" Margin="0,0,0,0">
<StackPanel Grid.Row="4" Height="40" Orientation="Horizontal" Margin="0,0,0,0">
<TextBlock Text="Date" FontSize="22" TextAlignment="Left" Width="170"/>
<TextBlock Text="FC" FontSize="22" TextAlignment="Left" Width="60"/>
<TextBlock Text="Max" FontSize="22" TextAlignment="Right" Width="60"/>
<TextBlock Text="Min" FontSize="22" TextAlignment="Right" Width="90"/>
</StackPanel>
<Grid >
<StackPanel Height="40" Orientation="Horizontal" Margin="0,10,0,0">
<TextBlock Text="{Binding date}" FontSize="22" TextAlignment="Left" Width="150"/>
<TextBlock Text=" " FontSize="20"/>
<Image Source="{Binding weatherIconUrl}" Width="40" Height="40"/>
<TextBlock Text=" " FontSize="20"/>
<TextBlock Text="{Binding tempMaxC, StringFormat='\{0\} °C'}" FontSize="22" TextAlignment="Right" Width="70"/>
<TextBlock Text=" " FontSize="20"/>
<TextBlock Text="{Binding tempMinC, StringFormat='\{0\} °C'}" FontSize="22" TextAlignment="Right" Width="70"/>
</StackPanel>
</Grid>
</StackPanel>
</Grid>
在後面的代碼
WeatherInfoLowBar.DataContext = wio.forecasts;
for (int i = 0; i < wio.forecasts.Count(); i++)
// what code goes in here ???
你們是不是要顯示所有與結構類似於上面的代碼中的每個元素的天氣預報的列表。 –
雅,預測有很多預測,每個預測有日期,weathericonui,tempmaxc和tempminc,我想在網格堆棧面板中顯示每個這些,並且會有五個垂直排列,因爲我預測的計數= 5,就像這個http://developer.nokia.com/Community/Wiki/File:PTM_Weather01.png(用日期檢查下半部分) – LivingThing