vb.net - WPF DataGrid / LINQ Query (DataGrid new row not visible) -


i'm relatively new wpf/linq2entities. i've managed make progress stuck on 1 issue i've been researching:

1) have wpf datagrid populated based on collectionviewsource. collectionviewsource's source linq query.

    private context new qadbentities             dim qadbentitiesviewsource collectionviewsource      dim salesorderserialnumber_query = salesorders in context.tblsalesorders                            join serialnumbers in context.tblserialnumbers                            on salesorders.sales_order_id equals serialnumbers.sales_order_id                            salesorders.sales_order_id = 5                            select new {salesorders, serialnumbers}       qadbentitiesviewsource = ctype(me.findresource("qadbentitiesviewsource"), collectionviewsource)     qadbentitiesviewsource.source = salesorderserialnumber_query.tolist() 

here excerpt xaml datagrid:

            <datagrid x:name="tblserialnumbersdatagrid" autogeneratecolumns="false" enablerowvirtualization="true" canuseraddrows="true"               itemssource="{binding source={staticresource qadbentitiesviewsource}}" margin="293,44,10,16"                rowdetailsvisibilitymode="visiblewhenselected" grid.columnspan="2">               <datagrid.columns>                   <datagridtextcolumn x:name="kit_group_idcolumn" binding="{binding serialnumbers.kit_group_id}" header="kit group id" width="sizetoheader"/>                   <datagridtextcolumn x:name="notescolumn" binding="{binding serialnumbers.notes}" header="notes" width="sizetoheader"/>                   <datagridtextcolumn x:name="product_idcolumn" binding="{binding serialnumbers.product_id}" header="product id" width="sizetoheader"/>                   <datagridtextcolumn x:name="production_lead_idcolumn" binding="{binding serialnumbers.production_lead_id}" header="production lead id" width="sizetoheader"/>                   <datagridtextcolumn x:name="qa_personnel_idcolumn" binding="{binding serialnumbers.qa_personnel_id}" header="qa personnel id" width="sizetoheader"/>                   <datagridtextcolumn x:name="sales_order_idcolumn" binding="{binding serialnumbers.sales_order_id}" header="sales order id" width="sizetoheader"/>                 ....etc               </datagrid.columns>     </datagrid> 

2) problem: populating datagrid , making changes data works fine. however, the datagrid not showing new row @ bottom of grid add additional records.

i believe has linq query, because when populate datagrid in way:

            qadbentitiesviewsource = ctype(me.findresource("qadbentitiesviewsource"), collectionviewsource)             qadbentitiesviewsource.source = context.salesorderlistsq.tolist() 

....everything, including new row, functional. or pointers appreciate. again i'm pretty new , realize problem design whole. thanks.

actually, problem here not linqtoentities , not grid, ef. ef supports changes objects in collection, , change notification if add rows table (i.e. items objectset), not automatic adding of rows through collectionviewsource. if want that, can go dataset, or create "add new" command adds new item objectset , makes current item of collectionviewsource.

you can refresh collectionviewsource calling collectionviewsource.view.refresh, , can make item current item calling collectionviewsource.view.movecurrentto(newitem). however, in case of object query, might have run query again, i.e. repeat line collectionviewsource.source = ...

i found ef's support collection view sources erratic; depends on how entity list supported , not. first code returns objectquery, must executed again in order recognise changes underlying list, while second example returns objectset, supports adding , removing items , collection change notification, far know. so, in fact shoul dsay in first paragraph ef supports adding rows through collectionviewsource in cases...


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -