title: Getting a particular setter of a style object
body: <p>I was wondering how to <strong>retrieve a particular setter</strong> from a style object in code-behind in silverlight.</p>
  
  <p>I have a style S which is correctly loaded and applied to some object. Then <strong>during runtime i want to alter one particular setter of this style</strong> say its Background setter (Of course what i want is to alter the value of one particular setter).</p>
  
  <p>To do so i looked at the Setters <strong>collection</strong> which is of type <strong>SetterBaseCollection</strong> and contains all setters of this style. So far so good. This collection seems to include all setters as they are defined in XAML but how to do i get access to them ?</p>
  
  <p>When i iterate over this collection i am dealing with objects of type "Setter". But I don't know how to pick the one which contains the "Background" property.</p>
  
  <pre><code>// this works totally fine; the variable myStyle is getting the correct Style
  myStyle = this.Resources["myStyle"] as Style;
  
  // the myStyle.Setters collection seems to contain all setters of the style
  foreach (Setter s in myStyle.Setters) {
  
     // so now what to do to get the setter that sets the Background property of my style ??
  
    // my naive approach did not work:
    if (s.Property.ToString().equals("Background")) {
  
        // do something
    }
  }
  </code></pre>
  
  <p>(The Setter objects does have a Name attribute, which in fact is exactly what I want to accomplish a comparison with the string "Background" - and debugging offered that this attribute truly contains the string "Background". ... But it's a non-public attribute!</p>
  
  <p>It would be <strong>great</strong> if anyone would have any suggestions <strong>:)</strong> </p>
  
  <p><em>p.s. My local time is 03:00 AM so i am a bit tired and overworked - so please ask me to clarify my issue again in case you have troubles guessing what i need ;)</em></p>