我的列表框数据绑定有什么问题?

时间:2013-01-04 23:03:43

标签: wpf vb.net data-binding listbox

我主要在ComboBox es和DataGrid上进行数据绑定,我假设ListBox的工作方式相同,但看起来我错过了{{1}当我将Scan对象添加到我的可观察集合时,它仍然是空白的。知道我在这里缺少什么吗?

ListBox

扫描类:

    <ListBox Height="480" HorizontalAlignment="Left" Margin="551,77,0,0" Name="ListBox_scans" VerticalAlignment="Top" Width="415" ItemsSource="{Binding}" >
        <ListBox.ItemTemplate>
            <DataTemplate>
                <StackPanel>
                    <TextBlock Text="{Binding Path=time}" />
                    <TextBlock Text="{Binding Path=station_name}"/>
                    <TextBlock Text="{Binding Path=Barcode}"/>
                </StackPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>

然后我只用一些主代码绑定:

Public Class Scan
Public Property Barcode As String
Public FromStation As Station
Public DateTimeUTC As DateTime
Public ScanType As String 'LotID, Employee Badge, Break, Complete, Duplicate
Public Duplicate As Boolean = False
Public IsWIPCleanUp As Boolean = False
Public IsComplete As Boolean = False

Public Property station_name As String
    Get
        If (Not FromStation Is Nothing) Then
            Return FromStation.Name
        Else
            Return "Station: No Station"
        End If
    End Get
    Set(value As String)

    End Set
End Property


Public Property time As String
    Get
        Return DateTimeUTC.ToLocalTime.ToShortTimeString()
    End Get
    Set(value As String)

    End Set
End Property

End Class

0 个答案:

没有答案