Created a collection of items. Just in case, I stuffed a bunch of interfaces into it (then remove the unnecessary ones)
public class HighlightRulesCollection : DependencyObject, ICollection<HighlightRule>, INotifyCollectionChanged, ICollection, ICollectionViewFactory, IList, IList<HighlightRule>, IAddChild The bottom line is that I have the opportunity to define a collection in resources and then use it as StaticResources . But the trouble! Everything that I add to this collection in the xaml markup is not really added to it. That is, after initializing the collection, it is empty. What can be wrong?
UPD:
Here is a collection in resources
<Window.Resources> <local:HighlightRulesCollection x:Key="hlRules"> <local:HighlightRule HightlightedText="qwe"> <local:HighlightRule.Highlights> <local:HighlightBackgroung Brush="Yellow"/> <local:HighlightForeground/> </local:HighlightRule.Highlights> </local:HighlightRule> </local:HighlightRulesCollection> </Window.Resources> Here on it (in the same window)
<local:HighlightTextBlock TextWrapping="Wrap" Grid.Column="1" Text="{Binding Property}" HighlightRules="{StaticResource hlRules}"> But in the properties browser (at runtime)
As you can see, the collection is there, it is of the desired type, but it is empty.
For an example, here's a screen from a neighboring control (I directly added elements of the collection to it)


xaml- GardesICollection<HighlightRule>andIList<HighlightRule>, try removingICollection<HighlightRule>. Must earn - Gardes