windows phone 7 - Pivot control with item template works on emulator but not on actual device -
i have problem page displays when test against emulator. however, when run on device page empty!
i making pivot command item template, within pivot.itemtemplate have listbox listbox.itemtemplate
the code below should produce page titled 'pivot test' 3 pivot items: 'pivot 1', 'pivot 2', 'pivot 3'. within each pivot, there should list. 'pivot 1' there should 3 items in list: 'name 1', 'name 2', 'name 3'. 'pivot 2' there should 2 items in list: 'name 1', 'name 2'. 'pivot 3' there should 1 item in list: 'name 1'
here xaml:
... <controls:pivot x:name="pivot" title="pivot test"> <controls:pivot.headertemplate> <datatemplate> <textblock text="{binding titletext}" /> </datatemplate> </controls:pivot.headertemplate> <controls:pivot.itemtemplate> <datatemplate> <listbox itemssource="{binding list}"> <listbox.itemtemplate> <datatemplate> <stackpanel> <textblock text="{binding name}" /> </stackpanel> </datatemplate> </listbox.itemtemplate> </listbox> </datatemplate> </controls:pivot.itemtemplate> </controls:pivot> ...
and here code whole page:
public partial class pivottest : phoneapplicationpage { private list<randomobject> randomobjectlist = new list<randomobject>(); public pivottest() { initializecomponent(); randomobjectlist.add(new randomobject() { name = "name 1" }); randomobjectlist.add(new randomobject() { name = "name 2" }); randomobjectlist.add(new randomobject() { name = "name 3" }); bindpivot(); } private void bindpivot() { pivot.itemssource = new[] { new { titletext = "pivot 1", list = randomobjectlist }, new { titletext = "pivot 2", list = randomobjectlist.take(2).tolist() }, new { titletext = "pivot 3", list = randomobjectlist.take(1).tolist() } }; } }
i have 1 class fill random info list box:
public class randomobject { public string name { get; set; } }
running on emulator gives expected results shown here:
however, when run on device there nil shown! empty page, thing shows 'pivot test' @ top title of pivot command no pivot items , ofc no list boxes.
the code above not need additions, can create test project , copy/paste code above check.
what cause of this?
thanks in advance!
edit: forgot mention windows phone os 7.1 project. don't know if matters.
after trying few things found out utilize of anonymous types cause of page not displaying on device, not sure why though. when declare typed classes , using instead of anonymous types page displays fine on device.
windows-phone-7 windows-phone windows-phone-7-emulator
No comments:
Post a Comment