What is the scope of StaticResource within a WPF ResourceDictionary?

Up vote 9 down vote favorite 2 share g+ share fb share tw.

I have a WPF ResourceDictionary with the following TextBlock: The ResourceDictionary is included in App. Xaml under MergedDictionaries: Within the App. Xaml I have defined the BoolToVis converter (again, under Application.

Resources) When I start my app up - I get the following XamlParseException: "Provide value on 'System.Windows.Markup. StaticResourceHolder' threw an exception. " The InnerException is: "Cannot find resource named 'BoolToVis'.

Resource names are case sensitive. " I'm able to refer to this converter directly with App. Xaml (in fact, the particular XAML declaration is identical) and within other UserControls with no problems.

This particular bit of code also worked fine under the . NET 4.0 RC (and Beta2). This error only started happening when I upgraded to the .

NET 4.0 RTM. I'm able to work around it by declaring another BooleanToVisibilityConverter within MyResourceDictionary. Xaml and referring to it like so: Any reason why I should need to do this?

Wpf . Net-4.0 resourcedictionary link|improve this question edited Apr 20 '10 at 21:59 asked Apr 20 '10 at 21:44Nicolas Webb738513 100% accept rate.

Per MSDN: Resources in a merged dictionary occupy a location in the resource lookup scope that is just after the scope of the main resource dictionary they are merged into. Resources defined in App. Xaml cannot be seen by a merged ResourceDictionary.

I would think it makes more sense to define a converter used in a ResourceDictionary in the ResourceDictionary itself, or another ResourceDictionary which houses all your converters.

We'll probably take the second route. What's so bizzare is that this code ran just fine in the RC, but not the RTM. Our dev team is "mixed" in regards to who has what version.

As an early adopter, I drew the short straw :). Thanks! – Nicolas Webb Apr 21 '10 at 0:22.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions