dimanche 7 juin 2015

Data Binding SQLIte to Listbox(containing three controls) Windows phone 8

Iam new to implementing SQLITE DB & windows phone 8 app development...

Implemeted following startegy to retreive data to listbox which contains three other controls..

here is my XAML code..

<ListBox Height="Auto"   Name="TaskListBox" Margin="5,61,-1,298">

            <ListBox.ItemTemplate>

                <DataTemplate>
                    <Grid Background="Red" Height="480" Width="200">
                        <TextBlock Text="{Binding status }" Name="team1Name" Width="120" ></TextBlock>
                        <TextBlock Text="{Binding CreationDate }" Name="team3Name" Foreground="White" Width="120"  HorizontalAlignment="Center"></TextBlock>
                        <HyperlinkButton Content="{Binding Merid_FK }" Name="team2Name" Foreground="White"/>
                       <TextBlock Text="{Binding status}" Name="venue" Foreground="White" Height="67" Width="78"></TextBlock>
                    </Grid>

                </DataTemplate>
            </ListBox.ItemTemplate>

        </ListBox>

and my code behind

 private void Insert_Click(object sender, RoutedEventArgs e)      
    {

        using (var db = new SQLiteConnection(DB_PATH))
        {
          //  dbConn.Query<Task>("INSERT INTO Task  VALUES (1, ken,Karthik,3/9/2008 4:05:07 )");  //not  working...
    db.RunInTransaction(() =>
            {
db.Insert(new tasks() { Merid_FK = 126745, status = "Y", CreationDate = DateTime.Now });
db.Insert(new tasks() { Merid_FK = 1289906, status = "N", CreationDate = DateTime.Now });
 });
}

 private void Retrieve_Click(object sender, RoutedEventArgs e)      
    {
        List<tasks> listmerchant = dbConn.Query<tasks>("SELECT STATUS from tasks where status='" + "Y" + "'").ToList<tasks>();
      TaskListBox.ItemsSource = listmerchant;
}

at listmerchant list (while debugging) iam getting sqlite result as "SQlite.Temp.tasks"

my tasks class

public sealed class tasks
{
    //[PrimaryKey,AutoIncrement]
    public int Merid_FK { set; get; }
    public string status { set; get; }
    public DateTime CreationDate { set; get; }
}

my problem is ,iam not getting any kind of display in UI.. at the same time result in code behind is "SQlite.Temp.tasks"(if we drill the drop down then its showing the columns data..please help me with this.. i already followed lot of similar questions in stack over flow,..

Slect data from SQLite

bind data to list box

bind data dynamically

Aucun commentaire:

Enregistrer un commentaire