开发者

Silverlight how to create attached properties that can only be placed in children

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜