xaml - Using the same ListView on two PivotItems without code duplication -
i'm working on shopping windows phone 8.1 application, have "promotions" page. page pivot page 2 pivotitems. first item shows top 100 promotions, , second item shows promotions. data call webservice. data has same structure in both cases, use same listview , datatemplate on both pages. question is: how can avoid code duplication in scenario? how can use same listview , datatemplate on 2 pivotitems without copy-pasting xaml , code?
you need create property in viewmodel takes filter of first this:
public observablecollection<itemmodel> itemlist { get; set; } public ienumerable<itemmodel> top100list { { return (from in itemlist select i).take(100); } }
then bind each listview appropriate property. example assumes top 100 items first 100 items in list. if not, either have modfy linq statement or sort list when adding items.
Comments
Post a Comment