0
IM試圖讓ListBox中的一個文本塊的值時,該項目被選中檢索TextBlock的標籤內的ListBox WP
public MainPage()
{
Startup.checknetwork();
InitializeComponent();
this.Loaded += new RoutedEventHandler(Load_List);
}
private void Load_List(object sender, RoutedEventArgs e)
{
XDocument loadedData = XDocument.Load("List.xml");
List<XElement> elements = loadedData.Descendants("ItemTitle").ToList();
List<RSSItem> aux = new List<RSSItem>();
foreach (XElement rssItem in elements)
{
RSSItem rss = new RSSItem();
rss.Title1 = rssItem.Element("Title").Value;
rss.Date1 = rssItem.Element("Uri").Value;
aux.Add(rss);
TextBlock One = new TextBlock();
One.Text = rss.Title1;
One.Tag = rss.Date1;
AListBox.Items.Add(One);
}
}
private void AList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var SelectedItem = ((TextBlock)sender).Tag as String;
}
一切加載了罰款,使用的Debug.WriteLine它顯示了正確的文本框的文本和標籤的alist顯示列表。 怎麼過,如果我選擇一個項目,我只是得到一個錯誤
有人能告訴我什麼我做錯了 感謝