Reputation: 4701
How can I insert existing object (from static field) into ResourceDictionary in a way that is equivalent to instantiating it there directly, ie. referencing resource with {StaticResource name}
must return object instance and not some wrapper (like ObjectDataProvider).
Upvotes: 1
Views: 901
Reputation: 4701
UPDATE
Unfortunately StaticExtension
does not work in all cases, it looks like it just inserts StaticExtension
object that is convertible to underlying source but it does not work in all contexts (for example when passing parameter value to markup extension).
Actual value is only inserted when using markup syntax {x:Static my:Foo.Bar}
but that's only possible for properties while I need collections.
It seems I can do that with StaticExtension
but for some reason not directly inside Application.Resources
.
<x:Static Member="my:MyEnum.One" x:Key="one" />
It does work directly inside Resources of other classes and also in Application class if I wrap everything with explicit <ResourceDictionary>
.
This is the error during compilation for the faulty case:
Error 3 Program 'X:\y\prog.exe' does not contain a static 'Main' method suitable for an entry point
Also, VS2010 crashed soon after when I started editing MainWindow.xaml.
Upvotes: 1