c# - OnPropertyChanged between windows - WPF -


before all, i'm sorry english not native. so, developing wpf application, thow windows, 1 present many button records on db , little form add new one, have 1 problem. when add record db onpropertychanged not fire , new buttons doesn't show up, think because datacontext.

lugareswindow.xaml

 <itemscontrol itemssource="{binding lugaresbtns}" margin="0,35,0,0">             <itemscontrol.itemspanel>                 <itemspaneltemplate>                     <uniformgrid columns="7" />                 </itemspaneltemplate>             </itemscontrol.itemspanel>             <itemscontrol.itemtemplate>                 <datatemplate>                     <grid>                         <button content="{binding numero}" click="openlugar" tag="{binding idlugar}" horizontalalignment="left" margin="10,10,0,0" verticalalignment="top" width="96" height="30"/>                     </grid>                 </datatemplate>             </itemscontrol.itemtemplate>         </itemscontrol> 

lugareswindow.xaml.cs

private void addlugarbtn_click(object sender, routedeventargs e) {     //(datacontext lugarviewservice).addlugar("11","6969","a","","1"); **if use works!**     editlugarwindow window = new editlugarwindow(-1);     window.show();  } 

editlugarwindow.xaml.cs (confirm form add new record)

        if (lvs.addlugar(idparquetxt.text, numerotxt.text, sectortxt.text, matriculatxt.text, selected))         {             this.close();         } 

and on lugarviewservice.cs

   public bool addlugar(string idparque, string numero, string sector, string matricula, string tipo)     {         int newnumero, newtipo, newparque;          try         {             newparque = int.parse(idparque);             newnumero = int.parse(numero);             newtipo = int.parse(tipo);             pmclient.addlugar(newparque, newnumero, sector, matricula, newtipo, 1);                            onpropertychanged("lugaresbtns");             return true;         }         catch (exception e)         {             messagebox.show("erro ao adicionar. por favor verifique o numero de lugar ou o tipo\n" + e.message);             return false;         }     }   public list<lugar> lugaresbtns {         {         return pmclient.getlugaresbyparque(idparque).tolist();      } } 

so, can see, lugareswindow.xaml doesnt updated after insert new record using window. doing wrong?

thank all!

it's solved, had set window.datacontext lvs instance using. thak replies.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -