對於某人來說,這看起來像是一個簡單的答案,所以我給了這個鏡頭,因爲我試圖解決這個問題已經翻了一番。將RSS綁定數據傳遞給另一個頁面,windows phone 7
我將RSS信息傳遞到帶有綁定數據的listbox
itemtemplate
。每個listboxitem都有一個圖片網址。我希望用戶能夠點擊listboxitem,將圖像URL傳遞到新頁面,並打開顯示圖像的頁面。
唯一的問題是?我無法得到這個工作。
這是我到目前爲止有:
第1頁XAML:
<ListBox x:Name="listbox" Grid.Row="1" SelectionChanged="listbox_SelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Image Grid.Row="0" HorizontalAlignment="Left" Height="60" Width="60" Source="{Binding Url}"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
第1頁CS
private void listbox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var URLname = "";
URLname = (sender as RssItem).Url.ToString();
NavigationService.Navigate(new Uri("/SubmittedPic.xaml?image=" + URLname, UriKind.Relative));
this.listbox.SelectedItem = (sender as ListBoxItem);
}
的代碼打破URLname = (sender as RssItem).Url.ToString();
,它是說,一個空引用異常未處理。
對此的任何幫助將不勝感激。