c# - wpf binding change of binding source -


i have following class main window:

public partial class window1 : window {     public network network { get; set; }     public dataset data_set { get; set; }     public training training { get; set; }      public string currentfile { get; set; }      public mgtester tester;     public mctester testersse;      public chartwindow errorwindow;     public chartwindow timeswindow;      public window1()     {         network = new network();         data_set = new dataset();         training = new training();         tester = new mgtester();         testersse = new mctester();         currentfile = "";         errorwindow = new chartwindow();         timeswindow = new chartwindow();          initializecomponent();          (int = 0; < tester.getdevicecount(); ++i)         {             devicecombobox.items.add(tester.getdevicename(i));         }     }... 

and in xaml code have:

<listview grid.row="0" x:name="networklistview" itemssource="{binding network.layers}" issynchronizedwithcurrentitem="true">                     <listview.view>                         <gridview>                             <gridviewcolumn width="100" header="layer name" displaymemberbinding="{binding name}"/>                             <gridviewcolumn width="60" header="neurons" celltemplate="{staticresource neuronstemplate}"/>                             <gridviewcolumn width="110" header="activation" celltemplate="{staticresource activationtemplate}"/>                         </gridview>                     </listview.view>                 </listview> 

anyway binding member of window1... , works fine want change member controlls binded - mean want somthing in window1

this.network = new network(); 

when binding stops working - how can , nicely "refresh" binding?

if binding source not ui-class, use notifying property instead of auto one.

http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged.aspx

public class myclass : inotifypropertychanged {     private network _network;      public network network     {                 {             return _network;         }         set         {             if (value != _network)             {                 _network = value;                 notifypropertychanged(value);             }         }     }       protected notifypropertychanged(string propertyname)     {         if (propertychanged != null)             propertychanged(this, new propertychangedeventargs(propertyname));     }  } 

if source class ui-class, define network dependencyproperty:

http://msdn.microsoft.com/en-us/library/system.windows.dependencyproperty.aspx

example quoted above link:

 public class mystatecontrol : buttonbase {   public mystatecontrol() : base() { }   public boolean state   {     { return (boolean)this.getvalue(stateproperty); }     set { this.setvalue(stateproperty, value); }    }   public static readonly dependencyproperty stateproperty = dependencyproperty.register(     "state", typeof(boolean), typeof(mystatecontrol),new propertymetadata(false)); } 

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -