如果我将一段文本分配给 a 的Content属性,则在渲染时会生成ContentPresenter一个TextBlock控件ContentPresenter来包含该文本。
如果我创建一个适用于TextBlock属性的样式并将其分配给 that ContentPresenter,则 似乎不适用于隐式生成TextBlock的 s。
<Style x:Key="SampleStyle">
<Setter Property="TextBlock.TextWrapping" Value="Wrap"/>
</Style>
<ContentPresenter Content="This is a Test piece of text." Style="{StaticResource SampleStyle}"/>
有没有办法将此样式成功应用于自动生成TextBlock的 s 而不是将其应用于所有TextBlocks (例如,将样式声明为TargetType="TextBlock"no Key)?