每个选定项目的Silverlight ListBox [英] Silverlight ListBox for each selected item

查看:80
本文介绍了每个选定项目的Silverlight ListBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这听起来很愚蠢,但花了我几个小时却无法正确解决.
如何从Silverlight列表框中获取selecteditem?

I know this may sound silly but took me a few hours and couldn''t get it right.
How to get selecteditem from the silverlight listbox?

Dim item As Object
For Each item In Me.ListBox1.SelectedItems
//here i just could not do it.
Next



这是填充列表框的服务



This is the service that populate the listbox

Dim proxy As New ...()
AddHandler proxy.GetDistrictCompleted, AddressOf Proxy_GetDistrictCompleted
proxy.GetDistrictAsync()

Me.ListBox1.ItemsSource = e.Result
Me.ListBox1.DisplayMemberPath = "District"
Me.ListBox1.SelectedValuePath = "District"


我知道从ASP内向外,但silverlight似乎有所不同.


I know inside out on the asp but silverlight seems to be different.

推荐答案

只需将item 强制转换为您的特定数据类类型.

我不确定为此使用VB语法,但是在C#中,您可以这样做:

Just cast item to your specific data class type.

I am not sure of the VB syntax for this, but in C# you''d do this:

MyType myType = (MyType)item;
DoStuff(myType.MyProperty, etc...);


尝试类似的方法:
Try something like:
Dim lbi As ListBoxItem = TryCast(TryCast(sender, ListBox).SelectedItem, ListBoxItem)
textBlock1.Text = " You selected " + lbi.Content.ToString() + "."



在示例此处查看全部详细信息 [ ^ ].



Have a look at full detail with sample here[^].


这篇关于每个选定项目的Silverlight ListBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆