title: C# INotifyPropertyChanged on properties of a dynamically created object?
body: <p>(update) ICustomTypeDescriptor works for my Windows Forms app, but not for Silverlight; Not supported. I will keep investigating this idea though and see where i get to.
  (/update)</p>
  
  <p>I have, say a few switch panels (for those that like analogies).
  Each of these switch panels has switches that have a Name(string) can be in state(bool) of On or Off.
  The switchpanel and switches are objects that have INotify interface on them.</p>
  
  <p>Using the switches Names, I create a list of all possible switch names over the collection and create a dynamic class that has all these Names as properties.</p>
  
  <pre><code>SwitchPanel1 (Switches( Switch1 ("Main",On) , Switch2("Slave",Off)))
  SwitchPanel2 (Switches( Switch1 ("Bilge",On) , Switch2("Main",Off)))
  </code></pre>
  
  <p>Produces a collection of</p>
  
  <pre><code>(Main,Bilge,Slave)
  </code></pre>
  
  <p>And a dynamic class is produced that has the properties:</p>
  
  <pre><code>SwitchPanel : (SwitchPanel)
  Main : (Switch)
  Bilge : (Switch)
  Slave: (Switch)
  </code></pre>
  
  <p>The idea is that if the switch panel has a switch with the Name of the property, it is placed on that property. So using a bit of linq</p>
  
  <pre><code>propeties["Main"].SetValue(newSwitchType,SwitchPanel.Switches.FirstOrDefault(sw =&gt; sw.Name == "Main"));
  </code></pre>
  
  <p>I want to cast this new dynamic class to INotfyPropertyChanged AND catch the actual changes on these new properties, so if a switch changes state the dynamic object will report it.</p>
  
  <p>Why? It needs to be displayed in a list view and the list view I'm using has its binding by supplying the Property name, and not the binding path. </p>
  
  <p>It also attempts to catch INotify events by casting the object against INotifyPropertyChanged. This means it will sort and/or group when things change.</p>
  
  <p>If you know of a better way to do this let me know. Please.</p>