Load a listbox with two textblock from a database with LINQ windows phone

时光毁灭记忆、已成空白 提交于 2019-12-12 02:33:56

问题


I am trying to load a listbox with two textblock from a database with LINQ in windows phone 7.1. My problem is that data does not appear in the textblock. Maybe the problem is in the xaml code, but I don´t know.

This is the xaml code:

<controls:Pivot Title="CEBADEROS">
        <controls:PivotItem Header="Entradas">
            <ListBox x:Name="EntradasList"
                        Margin="0,0,-12,0">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Margin="0,0,0,17">
                            <TextBlock Text="{Binding Fecha_entrada}"
                                        TextWrapping="NoWrap" Margin="12,0,0,0"
                                        Style="{StaticResource PhoneTextExtraLargeStyle}" Height="60" />
                            <TextBlock Text="{Binding Numero}"
                                        TextWrapping="NoWrap" Margin="12,-6,0,0"
                                        Style="{StaticResource PhoneTextExtraLargeStyle}" Height="60" />
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </controls:PivotItem>
    </controls:Pivot>

`

I have defined the next class

Public Class ClaseAnimales_Entradas

    Public Property Fecha_Entrada As DateTime
    Public Property numero As Integer

    Sub New()
        MyBase.New()
    End Sub

    Sub New(Fecha_Entrada As DateTime, numero As Integer)
        Me.Fecha_Entrada = Fecha_Entrada
        Me.numero = numero
    End Sub
End Class

And I’m trying to load the list box with the next code:

Partial Public Class GestionPanorama
   Inherits PhoneApplicationPage

   Public CurrentListEntradas As New List(Of ClaseAnimales_Entradas)
   Public Sub New()
        InitializeComponent()
        cargarListEntradas()
    End Sub

    Public Sub cargarListEntradas()
        Dim ae = From Animales_Entrada In db.Animales_Entrada Where Animales_Entrada.Eliminado = 0 Select Animales_Entrada.Fecha_entrada, Animales_Entrada.Numero

        For Each ele In ae
            CurrentListEntradas.Add(New ClaseAnimales_Entradas(ele.Fecha_entrada, ele.Numero))
        Next
        EntradasList.ItemsSource = CurrentListEntradas
    End Sub
End Class

What am I doing wrong? I don´t have errors but the listbox is empty.

Thanks in advance!!! Javi

来源:https://stackoverflow.com/questions/21582770/load-a-listbox-with-two-textblock-from-a-database-with-linq-windows-phone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!