c# - Win 8 App Set text in data template -
im trying learn how make datatemplate in listviews in win 8 app
i have following code in xaml code
<!-- vertical scrolling item list --> <listview x:name="itemlistview" margin="120,0,0,60" itemssource="{binding source={staticresource itemsviewsource}}" selectionchanged="itemlistview_selectionchanged"> <listview.itemtemplate> <datatemplate> <grid height="110" margin="6"> <grid.columndefinitions> <columndefinition width="auto"/> <columndefinition width="*"/> </grid.columndefinitions> <border background="{staticresource listviewitemplaceholderbackgroundthemebrush}" width="110" height="110"> <image source="{binding image}" stretch="uniformtofill"/> </border> <stackpanel grid.column="1" verticalalignment="top" margin="10,0,0,0"> <textblock text="{binding title}" textwrapping="nowrap" fontfamily="global user interface"/> <textblock text="{binding subtitle}" textwrapping="nowrap"/> <textblock text="{binding description}" maxheight="60" fontfamily="global user interface"/> </stackpanel> </grid> </datatemplate> </listview.itemtemplate> </listview>
what cant work out how set text 3 text blocks title,subtitle & description picture in image
usually when page loads use following in itemlistview_loaded(object sender, routedeventargs e) method
itemlistview.items.add(convert.tostring(correct) + ". " + line.split(',')[6]);
but how do im stumped
any appreciated
mark
you'll have make class includes properties.
public class myitem { public string title { get; set; } public string subtitle { get; set; } public string description { get; set; } public string source { get; set; } }
then when add items:
var item = new myitem(); item.title = "title"; item.subtitle = "subtitle"; item.description = "some example description."; item.source = "assets/somefolder/someimage.png"; itemlistview.items.add(item);
that worked in app (airpett transit)
Comments
Post a Comment