c# - StaticResource is null even though it's defined in XAML? -
i've got bit of niche scenario i'm not expecting solve, thought i'd give shot:
i have windows forms user control, contains single elementhost
control has it's child
property set wpf / xaml user control.
i'm getting strange behaviour whereby xaml contains looks this:
<usercontrol> <usercontrol.resources> <somenamespace:myresource x:key="foo" /> </usercontrol.resources> <grid datacontext="{staticresource foo}"> ... </grid> </usercontrol>
i xamlparseexception
@ runtime, asking me provide value, though it's defined above.
i can see initializecomponent()
being called, that's far can step.
in code behind, in wpf / xaml user control, if before initializecomponent()
called add: this.resources["foo"] = new myresource()
works great again.
just confuse matters further, happens when use visual studio 2015 compile code - compiling using vs2013 (on same machine/no solution changes whatsoever) works perfectly.
has got ideas, or helps on how debug this?
Comments
Post a Comment