ContentPresenter within ControlTemplate cannot change attached dependency property
- by happyclicker
Why does the following simplified code not set the font-size of the TextBlock to 50?
<Window.Resources>
<ControlTemplate TargetType="ContentControl" x:Key="Test">
<ContentPresenter TextBlock.FontSize="50" />
</ControlTemplate>
</Window.Resources>
<Grid>
<ContentControl Template="{StaticResource Test}">
<TextBlock>Test should be rendered big</TextBlock>
</ContentControl>
</Grid>
If I change the value of the FontSize property, visual studio shows me the text in the size I want. After compiling or executing the app, the size of the textblock is always reset to its default size.
I have also tested various versions with styles and embedded resources but I end always in the situation that I cannot set attached dp's from within a ControlTemplate that contains a ContentPresenter. Is this by design?