wpf - Write markup extension as nested element -
is possible write markup extension nested element rather attribute? trying use boolean key resourcedictionary entries.
current code resourcedictionary key type string:
<usercontrol.resources> <my:objecttoresourceconverter x:key="statusconverter"> <resourcedictionary> <bitmapimage x:key="true" urisource="/testproject;/resources/open.png"/> <bitmapimage x:key="false" urisource="/testproject;/resources/closed.png" /> </resourcedictionary> </my:objecttoresourceconverter> </usercontrol.resources> desired code doesn't compile due to:
unrecognized tag x:key
xaml
... <bitmapimage urisource="/testproject;/resources/open.png"> <x:key> <x:boolean>true</x:boolean> </x:key> </bitmapimage> ...
well, yes, can declare markup extensions element syntax, x:key directive, not markup extension. described here, x:key not support element syntax in xaml 2006. if use xaml 2009 does, it's unlikely (or want to).
but if that, wouldn't help, because (in xaml 2006; xaml 2009 might different, didn't check) key of resource dictionary can set using string, x:type, or x:static. case, need define static property produces false, , set key using x:static.
edit part supporting string, x:type, , x:static not true. trusting of compiler error message (which says 'only string, typeextension, , staticextension supported.'). there @ least 1 other supported key type: componentresourcekey. there may more i'm forgetting or of unaware. in case, arbitrary markup extensions (like custom-defined 1 returns boolean) not supported.
Comments
Post a Comment