i trying update listbox form observablecollection don't know doing wrong exception below. new winrt.
the application called interface marshalled different thread. (exception hresult: 0x8001010e (rpc_e_wrong_thread))
<listbox x:name="userlist" horizontalcontentalignment="stretch" margin="12,41,12,12"> <listbox.itemtemplate> <datatemplate> <grid margin="10"> <grid.columndefinitions> <columndefinition width="20" /> <columndefinition width="150" /> <columndefinition width="*" /> </grid.columndefinitions> <textblock text="{binding title}" margin="3" grid.column="0" /> <textblock text="{binding description}" margin="3" grid.column="1" /> <textblock text="{binding title}" margin="3" grid.column="2" /> </grid> </datatemplate> </listbox.itemtemplate> </listbox> c# code.
protected override void onviewmodelcollectionchanged(object sender,system.collections.specialized.notifycollectionchangedeventargs e) { this.dispatcher.runasync(windows.ui.core.coredispatcherpriority.normal, () => { userlist.itemssource = items; }).astask().wait(); }
to update list, implement interfaceдля inotifypropertychanged
class userdata: inotifypropertychanged { public event propertychangedeventhandler propertychanged; private string _title; public string title { { return _title; } set { if (_title != value) { _title = value; if (propertychanged != null) { propertychanged(this, new propertychangedeventargs("title")); } } } } }
Comments
Post a Comment