Is it possible to manipulate DP value inheritance parents of Content descendants?
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
Take a simple demo first. Create a ContentControl named "Example" and apply the following style:
```xaml
<Setter Property="Foreground" Value="Black" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:Example">
<ContentPresenter TextElement.Foreground="Red" />
</ControlTemplate>
</Setter.Value>
</Setter>
```
And then, add the following code to the view:
```xaml
```
Run the program, and you'll see **a big BLACK text**, NOT RED.
I debugged the program and stepped into the place where DependencyProperty.GetValue works. Finally I found that the InheritanceParent property of that TextBlock is its logical parent "Example" not its visual parent.
It would be a problem to some controls with multiple contents like the following example:

I have to solve this problem by wrapping a border with a foreground set to every content element. How dull!
At the end. What I expect is that I can manipulate the descendants of ContentPresenter to make them inherit DP value from their visual ancestors.
Contributor guide
Assessment
This issue has not been assessed yet.