Xamarin c# ListView binding not working , equivalent xaml is working -
as heading states listview binding within xaml works , doesnt work in c#.
here's code snippet: xaml
<listview itemssource="{binding records}"> <listview.itemtemplate> <datatemplate> <textcell text="{binding}"> </textcell> </datatemplate> </listview.itemtemplate> </listview>
c#
listview lv = new listview(); lv.itemssource = classvminstance.records; var dt = new datatemplate(typeof(textcell)); dt.setbinding(textcell.textproperty, new binding("records")); lv.itemtemplate = dt;
classvminstance instance of viewmodel.
records observablecollection<string>
the xaml version works fine , shows text , c# version has empty list elements without text.
(i tested on same page 2 listview 1 xaml , other c# , xaml 1 shows text , c# version has same number of list items empty)
i believe itemssource property working in code binding not can me out.
try
dt.setbinding(textcell.textproperty, new binding("."));
Comments
Post a Comment