fahadash
fahadash

Reputation: 3281

ResourceDictionary vs Resources directly under Window.Resources

Please pardon me if this was already asked, I have done a quick search to find out if it was however.

My question is what is the difference between the following two

<Window.Resources>
 <ResourceDictionary>
   <local:SomeClass x:Key="myobj" />
 </ResourceDictionary>
</Window.Resources>

And

<Window.Resources>
 <local:SomeClass x:Key="myobj" />
</Window.Resources>

Upvotes: 1

Views: 543

Answers (1)

McGarnagle
McGarnagle

Reputation: 102743

They're completely equivalent. The ResourceDictionary object is implicitly assumed to be the child in the second example (MSDN calls it the "XAML implicit collection usage"). I only ever use the longer form when adding MergedDictionaries.

Upvotes: 1

Related Questions