hi use visual studio 2010 wpf , c# model view presenter pattern.
i have issues though. have search function filters observable collection based on criteria user inserts:
public void search(string criteria) { if (!string.isnullorempty(criteria) && criteria.length > 2) { var rez = ua in _listadress ua.naziv.toupper().indexof(criteria.toupper()) >= 0 || ua.inventurnibroj.tostring() == criteria select ua; //var rez = ua in _listadress // ua.naziv.toupper() == criteria.toupper() || ua.inventurnibroj.tostring() == criteria // select ua; //listadress = new observablecollection<adress>(_adressrepository.findbylookup(criteria)); ubrzajadress = new observablecollection<adress>(rez); statustext = string.format("{0} zaduzenih pronađeno.", ubrzajadress.count); } else { //listadress = new observablecollection<adress>(_adressrepository.listoprema()); var rez = ua in _listadress select ua; ubrzajadress = new observablecollection<adress>(rez); statustext = "prikaz svih zaduzenih."; } (int = 0; < this.view.tabs.items.count; i++) { opremalistview tab = (opremalistview)this.view.tabs.items[i]; if (tab != null && tab.name != null && tab.name.equals("sva oprema")) //if (tab.header.equals("sva oprema")) { opremalistview opremalistview = (opremalistview)tab.content; opremalistpresenter opremalistpresenter = opremalistview.presenter; opremalistpresenter.refresh(); } } }
and here refresh method:
public void refresh() { this.view.dg.itemssource = _applicationpresenter.ubrzajadress; }
now works. but, tab. how of application structured. unfortunately due large amount of data , tabs working slower in app new window biggest list shows in new window in wpf data grid.
now when try alter search upgrade window, though compiles no refresh, when enter new row, , search row, not shown.
here search tried change works window:
public void search(string criteria) { if (!string.isnullorempty(criteria) && criteria.length > 2) { var rez = ua in _listadress ua.naziv.toupper().indexof(criteria.toupper()) >= 0 || ua.inventurnibroj.tostring() == criteria select ua; //var rez = ua in _listadress // ua.naziv.toupper() == criteria.toupper() || ua.inventurnibroj.tostring() == criteria // select ua; //listadress = new observablecollection<adress>(_adressrepository.findbylookup(criteria)); ubrzajadress = new observablecollection<adress>(rez); statustext = string.format("{0} zaduzenih pronađeno.", ubrzajadress.count); } else { //listadress = new observablecollection<adress>(_adressrepository.listoprema()); var rez = ua in _listadress select ua; ubrzajadress = new observablecollection<adress>(rez); statustext = "prikaz svih zaduzenih."; } (int = 0; < this.view.tabs.items.count; i++) { testwindow tab = (testwindow)this.view.tabs.items[i]; if (tab != null && tab.title != null && tab.title.equals("sva oprema")) //if (tab.header.equals("sva oprema")) { testwindow opremalistview = (testwindow)tab.content; testwindowpresenter opremalistpresenter = opremalistview.presenter; opremalistpresenter.refresh(); } } }
this compiles doesn't refresh or anything. refresh is:
public void refresh() { this.view.dg.itemssource = _applicationpresenter.ubrzajadress; }
another interesting thing if search item before adding new item , show oprema, deleting in search text box , clicking search, program crashes error: invalid cast exception unhandled unable cast object of type 'system.windows.controls.tabitem' type 'inventar.views.opremalistview'.
i'm guessing has there not being tab open in program , therefore failing don't know how fix , appreciated. anyway don't understand , looking can get. thanks
Comments
Post a Comment