c# - Xaml Windows phone 8 -
c# - Xaml Windows phone 8 -
i show 6 values database in corresponding page horizontally illustration date|time|floor|zone|latitude|longitude page shows data|time|floor|zone , not show latitude , longitude below xaml code
<grid x:name="layoutroot" background="transparent"> <grid.rowdefinitions> <rowdefinition height="auto"/> <rowdefinition height="*"/> </grid.rowdefinitions> <!--titlepanel contains name of application , page title--> <stackpanel grid.row="0" margin="12,17,0,28"> <textblock text="smart parking" style="{staticresource phonetextnormalstyle}"/> <textblock text="history" margin="9,-7,0,0" style="{staticresource phonetexttitle1style}"/> </stackpanel> <!--contentpanel - place additional content here--> <grid x:name="contentpanel" grid.row="1" margin="12,0,12,0"> <listbox x:name="listdata"> <listbox.itemtemplate> <datatemplate> <stackpanel orientation="horizontal"> <textblock x:name= "datetxt" text="{binding date}" textwrapping="wrap" /> <textblock x:name= "timetxt" text="{binding time}" textwrapping="wrap" /> <textblock x:name= "zonetxt" text="{binding zone}" textwrapping="wrap"/> <textblock x:name= "floortxt" text="{binding floor}" textwrapping="wrap"/> <textblock x:name= "lattxt" text="{binding location_latitude}" textwrapping="wrap" /> <textblock x:name= "longtxt" text="{binding location_longitude}" textwrapping="wrap" /> </stackpanel> </datatemplate> </listbox.itemtemplate> </listbox> </grid> </grid>
can please help me improve or right ?
the code behind list itmesource here below
public partial class history : phoneapplicationpage { // string dbpath = path.combine(windows.storage.applicationdata.current.localfolder.path, "db.sqlite"); observablecollection<historytablesqlite> db_historylist = new observablecollection<historytablesqlite>(); dbhelper add together = new dbhelper(); public history() { initializecomponent(); } protected override void onnavigatedto(navigationeventargs e) { add.addinfo(); readhistorylist_loaded(); } public void readhistorylist_loaded() { readallcontactslist dbhistory = new readallcontactslist(); db_historylist = dbhistory.getallhistory();//get db contacts listdata.itemssource = db_historylist.orderbydescending(i => i.id).tolist();//latest contact id can display first }
here below dbhelper class main functions
public class dbhelper { sqliteconnection dbconn; public async task<bool> oncreate(string db_path) { seek { if (!checkfileexists(db_path).result) { using (dbconn = new sqliteconnection(db_path)) { dbconn.createtable<historytablesqlite>(); } } homecoming true; } grab { homecoming false; } } private async task<bool> checkfileexists(string filename) { seek { var store = await windows.storage.applicationdata.current.localfolder.getfileasync(filename); homecoming true; } grab { homecoming false; } } //retrieve list database public observablecollection<historytablesqlite> readhistory() { using (var dbconn = new sqliteconnection(app.db_path)) { list<historytablesqlite> mycollection = dbconn.table<historytablesqlite>().tolist<historytablesqlite>(); observablecollection<historytablesqlite> historylist = new observablecollection<historytablesqlite>(mycollection); homecoming historylist; } } // insert new info in histrorytablesqlite table. public void insert(historytablesqlite newcontact) { using (var dbconn = new sqliteconnection(app.db_path)) { dbconn.runintransaction(() => { dbconn.insert(newcontact); }); } } public void addinfo() { dbhelper db_helper = new dbhelper(); db_helper.insert((new historytablesqlite { date = datetime.now.toshortdatestring(), time = datetime.now.toshorttimestring(), zone = "pst", floor = "10th floor", latitude = 35.45112, longtitude = -115.42622 })); } }
and lastly class keeping values
public class historytablesqlite : inotifypropertychanged { [sqlite.primarykey, sqlite.autoincrement] public int id { get; set; } private int idvalue; private string datevalue = string.empty; public string date { { homecoming this.datevalue; } set { if (value != this.datevalue) { this.datevalue = value; notifypropertychanged("date"); } } } private string timevalue = string.empty; public string time { { homecoming this.timevalue; } set { if (value != this.timevalue) { this.timevalue = value; notifypropertychanged("time"); } } } private string floorvalue = string.empty; public string floor { { homecoming this.floorvalue; } set { if (value != this.floorvalue) { this.floorvalue = value; notifypropertychanged("floor"); } } } public string zonevalue; public string zone { { homecoming this.zonevalue; } set { if (value != this.zonevalue) { this.zonevalue = value; notifypropertychanged("zone"); } } } private double latvalue; public double latitude { { homecoming latvalue; } set { if (value != this.latvalue) { this.latvalue = value; notifypropertychanged("latitude"); } } } private double lonvalue; public double longtitude { { homecoming this.lonvalue; } set { if (value != this.lonvalue) { this.lonvalue = value; notifypropertychanged("longitude"); } } } // public string ismarkpoint { get; set; } public historytablesqlite() { } public historytablesqlite(string date,string time,string floor,string zone,double lat,double lng) { date = date; time = time; floor = floor; zone = zone; latitude = lat; longtitude = lng; } public event propertychangedeventhandler propertychanged; private void notifypropertychanged(string info) { if (propertychanged != null) { propertychanged(this, new propertychangedeventargs(info)); } } }
you binding textblock location_longitude
don't see location_longitude (or latitude) in code behind.
plus, have little misspelling in longitude
, latitude
declarations
public double longtitude // here alter longitude { { homecoming this.lonvalue; } set { if (value != this.lonvalue) { this.lonvalue = value; notifypropertychanged("longitude"); } } } private double latvalue; public double latitude // alter latitude { { homecoming latvalue; } set { if (value != this.latvalue) { this.latvalue = value; notifypropertychanged("latitude"); } } }
try bind textblock
<textblock x:name="lattxt" text="{binding latitude}" textwrapping="wrap" /> <textblock x:name="longtxt" text="{binding longitude}" textwrapping="wrap" />
hope help.
c# sqlite xaml windows-phone-8
Comments
Post a Comment