Dynamically Binding Data to ComboBox in Windows Store Apps using Sqlite Database

Create the table first:

public string Country

{

public string city

{

set;

get;

}

}
 

App.xaml.cs

Create the table :

db.createTable<country>();


Insert the default values in Table:

db.insert(new Country{City="Hyderabad"});

db.insert(new Country{city="Banglore"});

 
Xaml.cs
 

public MainPage()

{

this.InitializeComponent();

DropList();

}

 

public void DropLIst()

{

  var Dbpath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "Smart.db3")

  using (var db =new SQLite.SQLiteConnection(Dbpath))

  {

     var query = db.Table<Country>();

     var result =query.ToList();

     foreach (var item in result)

     {

       Country obj = new Country();

       cba.Items.Add(item.city);

     }

  }

}

 

Ebook Download
View all
Learn
View all