In Silverlight (or WPF for that matter) you can something like this:
<UserControl ...>
<UserControl.Resources>
<DataTemplate x:Key="SomeKey">...</DataTemplate>
<DataTemplate x:Key="AnotherKey">...</DataTemplate>
<DataTemplate x:Key="OneMoreKey">...</DataTemplate>
<UserControl.Resources>
...
Now when I have my own custom control which takes a collection of DataTemplates.
I cannot set x:Key on those DataTemplates, why not? (first question!)
Now I think it has something to do that my collection does not inherit from ResourceDictionary.
If that is the answer HOW do I create an attached property which can only be set on Children (Da开发者_高级运维taTemplates) of my own custom control?
I found AttachedPropertyBrowsableForType
but I cannot find it for Silverlight...
You are correct that x:Key is for Resources. What is this attached property for? You might be going about it the wrong way.
精彩评论