I want to use StaticResource in the root element of a xaml document. But MSDN says:
Static resource references from within a resource dictionary must reference a resource that has already been defined lexically before the resource reference. Forward references cannot be resolved by a static resource reference.
And this:
The lookup process then traverses the logical tree upward, to the parent element and its resource dictionary. This continues until the root element is reached.
Should I define my resource in the application or create it from code?
If you really need to access a ResourceDictionary from the root element, you may be able to reference it as a DynamicResource rather than a StaticResource - I'm not sure if it will work, but it could be worth a try.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With