请告诉我为什么Silverlight组合框不显示任何项目 [英] please advise me why silverlight combobox displays no items
问题描述
将第一个列表作为新列表(属性_死亡)
昏暗的a1作为新的Property_Deatils("ABCD","xyz")
昏暗的a2作为新的Property_Deatils("xyz","abcd")
lst.Add(a1)
lst.Add(a2)
Me.ComboBox1.ItemsSource = lst
----------------------------------------
公共类Property_Deatils
公共property_name作为字符串
公共Property_id作为字符串
子新建(ByVal property_name作为字符串,ByVal Property_id作为字符串)
Me.property_name = property_name
Me.Property_id = Property_id
结束子
结束类
-------------------------------------------
Dim lst As New List(Of Property_Deatils)
Dim a1 As New Property_Deatils("ABCD", "xyz")
Dim a2 As New Property_Deatils("xyz", "abcd")
lst.Add(a1)
lst.Add(a2)
Me.ComboBox1.ItemsSource = lst
----------------------------------------
Public Class Property_Deatils
Public property_name As String
Public Property_id As String
Sub New(ByVal property_name As String, ByVal Property_id As String)
Me.property_name = property_name
Me.Property_id = Property_id
End Sub
End Class
-------------------------------------------
推荐答案
您是否设置了ComboBox的DisplayMember?
Do you set the DisplayMember of the ComboBox ?
尝试添加diaplaymember但没有运气,请告知
Tried adding diaplaymember but no luck ,please advise
(终于,我摔了一天头后得到了答案
您需要在类property_details中将每个变量的属性添加为get和set,然后它将在运行时在Xaml文件中进行更新,如下所示,在XAML文件中引用名字,而不是fname
类My_class
公用fname作为String
公用lname作为String
公共属性名字为String
获取
返回fname
结束获取
设置(ByVal值作为字符串)
fname =值
端套
最终财产
公共属性姓氏为String
获取
返回lname
结束获取
设置(ByVal值作为字符串)
lname =值
端套
最终财产
结束类''MyClass
(finally i got the answer after breaking my head for one day
You need to add property for each varibales in the class property_details as get and set , then it will update in Xaml file during run time similar to below, refer firstname in the XAML file rather than fname ,
class My_class
Public fname As String
Public lname As String
Public Property firstname As String
Get
Return fname
End Get
Set(ByVal value As String)
fname = value
End Set
End Property
Public Property lastname As String
Get
Return lname
End Get
Set(ByVal value As String)
lname = value
End Set
End Property
End Class ''MyClass
这篇关于请告诉我为什么Silverlight组合框不显示任何项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!