2014-10-29 231 views
0

環境: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 

我想,如下圖中顯示的數據:

enter image description here

回答

0

您需要綁定到ITRDescriptionList的新的集合,包含的值,而不是直接到物業本身。

舉個例子,嘗試在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