Friday, 15 July 2011

c# - WPF Data Form Paging -



c# - WPF Data Form Paging -

i trying create info form has set of fields , paging buttons in bottom of form.

i paging separate command first, previous, next, lastly label item 1 of n.

this paging command used info entry form allow user , forth between previous record. example, orders, invoices, payments info forms. user when selects orders, new order form shown. has paging buttons move previous record.

i created usercontrol named datapager dependency property of pagingitems. want dependency property generic can pass list of items (order, invoice, payment)

for did: list in user control. tried binding in form needs page.

public list<object> items { { homecoming (list<object>)getvalue(itemsproperty); } set { setvalue(itemsproperty, value); } } // using dependencyproperty backing store items. enables animation, styling, binding, etc... public static readonly dependencyproperty itemsproperty = dependencyproperty.register("items", typeof(list<object>), typeof(datapager), new uipropertymetadata(null, loaditems)); private static void loaditems(dependencyobject obj, dependencypropertychangedeventargs e) { datapager thiscontrol = (datapager)obj; thiscontrol.refreshitems(); }

i getting next error in page utilize command , bind:

system.windows.data error: 1 : cannot create default converter perform 'one-way' conversions between types 'system.collections.generic.list`1[pagingsample.order]' , 'system.collections.generic.list`1[system.object]'. consider using converter property of binding. bindingexpression:path=orders; dataitem='mainviewmodel' (hashcode=26754911); target element 'datapager' (name='datapager1'); target property 'items' (type 'list`1') system.windows.data error: 5 : value produced bindingexpression not valid target property.; value='system.collections.generic.list`1[pagingsample.order]' bindingexpression:path=orders; dataitem='mainviewmodel' (hashcode=26754911); target element 'datapager' (name='datapager1'); target property 'items' (type 'list`1')

not sure how can maintain datapager controls item property generic. have not figured out yet how tell parent command currentitem show.

but wanted clear first hurdle. help appreciated.

you can't cast list<order> list<object> - that's why you're getting error.

if datapager command needs command page displayed, , not modify collection, define items property of type ienumerable instead of list<object>, , problem solved.

this because t, list<t> castable ienumerable.

c# .net wpf paging datapager

No comments:

Post a Comment