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