Windows Phone: Adding XAML Tags by C#-Commands -
windows phone 8 app (c#):
- i have array peoples first name, last name , employee number.
- this array does not have fixed length.
- in xaml, i'm trying show list of peoples names, linking page we'll need employee number.
now, have idea if it's possible add many xaml textblocks array length?
they this:
<textblock x:name="first" text="" horizontalalignment="left" margin="0,(*x*+50),0,0" textwrapping="wrap" verticalalignment="top" height="50" width="445"/>
the girl started developing app put in 30 textblock-tags , used maaany if-statements in order fill these, if data available those. possible solution? :(
thank help! kind regards, rebecca
xaml code
<listbox x:name="lstbx"> <listbox.itemtemplate> <datatemplate> <stackpanel orientation="horizontal"> <textblock text="{binding firstname}" foreground="red"></textblock> <textblock text="{binding lastname}" foreground="green"></textblock> <textblock text="{binding employeenumber}" foreground="blue"></textblock> </stackpanel> </datatemplate> </listbox.itemtemplate> </listbox>
c# code
public class person { public string firstname { get; set; } public string lastname { get; set; } public int employeenumber { get; set; } public person(string firstname, string lastname, int employeenumber) { this.firstname = firstname; this.lastname = lastname; this.employeenumber = employeenumber; } } protected override void onnavigatedto(navigationeventargs e) { var data = new person[] { new person("fistname1","lastname1",1), new person("fistname2","lastname2",2), new person("fistname3","lastname3",3), new person("fistname4","lastname4",4), }; lstbx.itemssource = data; }
Comments
Post a Comment