English 中文(简体)
Window phone 7电话 7 Listbox 选择集成数据
原标题:Windows Phone 7 Listbox selection data binding

我使用< a href=> http://www.netmagazine.com/tutorics/building- your first-windows-phone-7-app" rel=“no follow” 来作为我第一个应用程序的基础。 我试图选择一个列表框项目并从该条目上查看数据, 但是(我的机器人和iOS大脑对此有问题), 我如何看待此背后的数据?

lstContact.ItemsSource = from contact in xmlContact.Descendants("contact")
                                 select new ContactItem
                                 {
                                     ImageSource = contact.Element("Image").Value,
                                     FName = contact.Element("FName").Value,
                                     LName = contact.Element("LName").Value
                                     Extension = contact.Element("Extension").Value,
                                     Email = contact.Element("Email").Value,
                                     ID = contact.Element("ID").Value
                                 };

这就是我如何设置数据源的, 并且它正在正确拉动。 我该如何进入和从上述列表框中获取电子邮件或扩展名?

最佳回答

在您的示例中, lst Contact.Trojects源 实际上是现在的 >IE numberable<contactAtroduction> 。 假设您想要在您的 chose- changed 事件中选中的项目 :

public void ListBoxContainerSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (lstContact.SelectedIndex == -1) return; 
            ContactItem contactItem = (ContactItem)lstContact.SelectedItem; 
            /*do something */ 
            lstContact.SelectedIndex = -1;
}
问题回答

暂无回答




相关问题
WPF: How to limit number of rows shown by ListBox?

Is it possible to limit the number of rows a listbox show? Eg. let´s say I have a ItemSource with 100 items, but I only want my listbox to be 10 items high.

ListBox Value containing links

hi I am currently working on improving the SEO on a website containing dropdown list menu. currently when you select options and then submit a javascript is redirecting you to the next page I heard ...

asp.net listbox double click event + event handler

I am trying to add a double-click event in a listbox. But I am getting the following error. the aspx file <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ListBox__Test.aspx.cs" ...

How to insert ComboBox item into ListBox? [winforms]

The question is very simple, How to insert ComboBox selected item into ListBox using c#? I have tried with this: listbox.Items.Add(combobox.SelectedItem); and some other permutations but it always ...

listbox itemtemplate for selected item

I am using Listbox with ItemTemplate, and when I select an item from the list, it shows blue background How can I style the selected item, to be similar to non-selected one?

WPF Data Binding Error in ListBox

I have a ListBox: <ListBox x:Name="HistogramListBox" Grid.Column="1" Margin="8,2,8,0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Template="{StaticResource ...

How do I anchor an expander to right side of a ListBox?

The XAML code below works fine except I want the expander button to be between the listbox and the grid. If I set the ExpandDirection="Left" the button is between the listbox and the grid but the ...

Adding Items to ListBox, RadioList, Combobox using reflection

I m trying to add items to a listbox,combobox, radiolist using reflection. The code I have at the moment is as follows: public static Control ConfigureControl(Control control, ControlConfig ctrlconf)...

热门标签