Windows Phone ListPicker passing SelectedItem
本文关键字:SelectedItem passing ListPicker Phone Windows | 更新日期: 2023-09-27 17:56:04
我正在使用rss阅读器示例和listPicker。我想做的是将 rss url 从 listPicker 项传递到 webClient.DownloadStringAsync。
**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"));
[...]
我不知道如何解决这个问题。这个问题有简单的解决方案吗?
您可以将 id 传递给选择更改事件的 URL。是否正在尝试预加载列表项上的信息?