I’ve got a somewhat special problem: I have a markup extension that needs to check an attached property. The attached property is defined as inheritable.
This works properly in XAML for all elements that are defined under a Window/UserControl, but not for resources. For example, given this XAML:
<Window MyAttachedProp="...">
<Window.Resources>
<FlowDocument x:Key="Doc">
<Paragraph><Run Text="{MyMarkupExtension}" /></Paragraph>
</FlowDocument>
</Window.Resources>
<FlowDocumentScrollViewer Document="{StaticResource Doc}" />
...
</Window>
The markup extension fails because when the ProvideValue()-function is called, the attached property is not derived from the Window to the FlowDocument and to the Run.
Is there same workaround to make this work?
Thanks,
Steven
From Inheriting Property Values Across Tree Boundaries:
Apparently a resource dictionary does not constitute an element tree and hence the value won’t be inherited. However, i guess it should work when you set the property on the FlowDocument, since that is the root of an element tree: