环境:silverlight 4.0
我将数据绑定到Silverlight Accodion控件但不显示我的代码数据如下:
<layout:Accordion HorizontalAlignment="Left" Name="accordion1" Width="761" Height="205" Background="SkyBlue" VerticalAlignment="Top" Margin="32,404,0,0">
<layout:Accordion.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding ITRUserName}" />
</StackPanel>
</DataTemplate>
</layout:Accordion.ItemTemplate>
<layout:Accordion.ContentTemplate>
<DataTemplate>
<TextBlock Text="{Binding ITRUserName}" />
</DataTemplate>
</layout:Accordion.ContentTemplate>
</layout:Accordion>
xaml.cs:
accordion1.ItemsSource = ITRDescriptionlist
Public Property _itrdescription As New List(Of ITRDescription)
Public Property ITRDescriptionList() As List(Of ITRDescription)
Get
Return _itrdescription
End Get
Set(ByVal value As List(Of ITRDescription))
_itrdescription = value
End Set
End Property
Public Class ITRDescription
Private Property _ITRDescription As String
Public Property ITRDescription() As String
Get
Return _ITRDescription
End Get
Set(ByVal value As String)
_ITRDescription = value
End Set
End Property
Private Property _ITRDate As String
Public Property ITRDate() As String
Get
Return _ITRDate
End Get
Set(ByVal value As String)
_ITRDate = value
End Set
End Property
Private Property _ITRUsername As String
Public Property ITRUserName() As String
Get
Return _ITRUsername
End Get
Set(ByVal value As String)
_ITRUsername = value
End Set
End Property
End Class
我想显示数据,如下图所示:
答案 0 :(得分:0)
您需要绑定到包含值的新ITRDescriptionList集合,而不是直接绑定到Property本身。
例如,尝试将它放在xaml.cs中的Public Sub New()中,在InitializeComponent()
下Public Sub New()
InitializeComponent()
ITRDescriptionList = New List(Of ITRDescription)
ITRDescriptionList.Add(New ITRDescription With {.ITRDate = Date.Today, .ITRDescription = "Test Description", .ITRUserName = "Joe Bloggs"})
accordion1.ItemsSource = ITRDescriptionList
End Sub