.net - wpf UI is not updating when EF 5 entity is reloaded -
i have mmvm wpf 4.5 application uses entity framwork 5 info model. have list of clients observable collection utilize source collectionviewsource can sort/filter etc.
i have undo button supposed original values selected client , replace current values of client.
the info access looks this:
public function getclient_all() observablecollection(of client) implements iclientdataservice.getclient_all seek dim clientquery iqueryable(of client) = ctype((from c in ftccontext.clients select c), iqueryable(of client)) homecoming new observablecollection(of client)(clientquery) grab ex exception homecoming nil end seek end function in view model utilize observable collection this:
clients = _clientaccess.getclient_all ''sets observable collection source of collectionviewsource _clientcollectionviewsource.source = clients the wpf xaml binding looks selection property used master detail relationship between listview , content control:
<listview grid.column="1" width="350" style="{dynamicresource ftc_listview}" itemtemplate="{dynamicresource ftc_clientlisttemplate}" itemcontainerstyle="{dynamicresource ftc_listviewitem}" selectionmode="single" itemssource="{binding clientviewsource.view}" selecteditem="{binding path=selection, mode=twoway}"/> <scrollviewer grid.column="1" horizontalalignment="stretch" verticalalignment="stretch"> <contentcontrol datacontext="{binding path=selection, mode=twoway}" > <!-- binding properties selection object go here --> </contentcontrol> </scrollviewer> i utilize next code execute undo changes function current client supposed homecoming client original values:
private sub undoexecute() ''reload current client entity info context ftccontext.entry(ftccontext.clients.find(selection.idclient)).reload() '' next hacks ui create sure updates dim currentposition integer = clientviewsource.view.currentposition clientviewsource.view.movecurrenttolast() clientviewsource.view.movecurrenttofirst() clientviewsource.view.movecurrenttoposition(currentposition) raisepropertychanged("selection") end sub so problem when phone call .reload() entity in fact reloaded database unchanged values, ui not updated unless set above hack undo sub. above "hack" moves selection in collectionviewsource away , initial client, date ui. if don't ui not updated original values of client. hope makes sense.
i don't know why happening , not have "hack" in undo execute sub. can help me understand why ui isn't updating?
.net wpf vb.net entity-framework entity-framework-5
No comments:
Post a Comment