1
我正在使用rss reader sample和listPicker。我想要做的是將rss url從listPicker項傳遞給webClient.DownloadStringAsync。Windows Phone ListPicker傳遞SelectedItem
**MainPage.xaml**
[...]
<toolkit:ListPicker.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Nazwa}"
Margin="12 0 0 0"
VerticalAlignment="Center"/>
<Image Source="/Repertuar;component/Images/open.png" FlowDirection="RightToLeft" />
</StackPanel>
</DataTemplate>
</toolkit:ListPicker.ItemTemplate>
<toolkit:ListPicker.FullModeItemTemplate>
<DataTemplate>
<StackPanel Margin="16 21 0 20">
<TextBlock Text="{Binding Nazwa}"
FontSize="43"/>
</StackPanel>
</DataTemplate>
</toolkit:ListPicker.FullModeItemTemplate>
[...]
。
**MainPage.xaml.cs**
[...]
public class Miasto
{
public string Nazwa
{
get;
set;
}
public string Adres
{
get;
set;
}
}
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
IEnumerable<Miasto> source = this.GetDataSource();
this.listPicker.ItemsSource = source;
}
private IEnumerable<Miasto> GetDataSource()
{
List<Miasto> source = new List<Miasto>();
source.Add(new Miasto() { Nazwa = "Bydgoszcz", Adres = "http://film.wp.pl/rss.xml?id=10" });
source.Add(new Miasto() { Nazwa = "Gdańsk", Adres = "http://film.wp.pl/rss.xml?id=27" });
return source;
}
[...]
webClient.DownloadStringAsync(new System.Uri("http://film.wp.pl/rss.xml?id=27"));
[...]
我不知道如何解決這個問題。這個問題有沒有簡單的解決方案?
我完全不熟悉這個東西,恐怕我愚蠢地實施你的解決方案的想法。通過預加載信息,你的意思是什麼? –
當您點擊列表選擇器項目時是否嘗試加載信息?如果是這樣,你可以在private void listPicker_SelectionChanged(object sender,SelectionChangedEventArgs e) –