12

Every time I write out a setter whose Value property value isn't describable inline, I curse the fact that the API doesn't mark the Setter class with [ContentProperty("Value")], which would allow this:

<Setter Property="BitmapEffect">
  <Setter.Value>
    <OuterGlowBitmapEffect GlowColor="#AAC" Opacity="0.2" GlowSize="1.25" />
  </Setter.Value>
</Setter>

...to be simplified to this:

<Setter Property="BitmapEffect">
  <OuterGlowBitmapEffect GlowColor="#AAC" Opacity="0.2" GlowSize="1.25" />
</Setter>

So my question is kinda twofold. Firstly, is there a good reason that the API hasn't been configured this way? Secondly, is there anything stopping my making this metadata available to the XamlReader somehow, even though I don't control the WPF API?

Emond
  • 50,210
  • 11
  • 84
  • 115
Drew Noakes
  • 300,895
  • 165
  • 679
  • 742

2 Answers2

3

Ten years and eighteen days after asking this question, the newly open-sourced WPF has a PR submitted that fixes this:

https://github.com/dotnet/wpf/pull/745

Drew Noakes
  • 300,895
  • 165
  • 679
  • 742
2

Good point indeed... But you could easily create your own Setter class inherited from System.Windows.Setter, put the ContentProperty attribute on it, and use it instead of the standard Setter.

Thomas Levesque
  • 286,951
  • 70
  • 623
  • 758