private static void OnParagraphInlineChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { Paragraph paragraph = d as Paragraph; IEnumerable inlines = ParagraphInlineBehavior.GetParagraphInlineSource(paragraph); var changed = inlines as INotifyCollectionChanged; if (inlines != null && changed != null) { var wrapper = new ObservableCollectionWrapper(paragraph, changed); wrapper.Wrap(); } }
public ObservableCollectionWrapper(Paragraph paragraph, INotifyCollectionChanged collectionChanged) { _paragraph = paragraph ?? throw new ArgumentNullException(nameof(paragraph)); _collectionChanged = collectionChanged ?? throw new ArgumentNullException(nameof(collectionChanged)); _collection = collectionChanged as IEnumerable; if (_collection == null) { throw new ArgumentNullException(nameof(collectionChanged)); } _templateName = ParagraphInlineBehavior.GetTemplateResourceName(_paragraph); }