silverlight - Strange behaviour when not using dispatcher -
i know must use dispatcher whenever try access ui element different thread, today encountered want ask about. have list populated objects of class row ( custom class) , each row populated cell(custom class). each cell has property cellwidth. populate list inside viewmodel , pass view make observablecollection out of list. grid's width bound cellwidth in ui. so, if set width not using dispatcher ( inside viewmodel), grid ignores binding, if use , works fine. (note: exception not raised when don't use dispatcher)
the question is: why happening? thought issue dispatcher addresses threading...
public mainpageviewmodel() { idatatablemodel table1 = new observablecollection<row>(); setcellwidth(table1); } private void setcellwidth(idatatablemodel model) { list<double> widths = new list<double>(); //initializing widths values <...> deployment.current.dispatcher.begininvoke(() => { foreach(var item in model.rows) { for(int = 0; i<item.cells.count; i++) { item[i].cellwidth = widths[i]; } } }); }
Comments
Post a Comment