是否可以向文本块添加边框?我需要将它添加到代码如下的setter属性中:WPF向文本块添加边框
<Style x:Key="notCalled" TargetType="{x:Type TextBlock}">
<Setter Property="Margin" Value="2,2,2,2" />
<Setter Property="Background" Value="Transparent" />
</Style>
是否可以向文本块添加边框?我需要将它添加到代码如下的setter属性中:WPF向文本块添加边框
<Style x:Key="notCalled" TargetType="{x:Type TextBlock}">
<Setter Property="Margin" Value="2,2,2,2" />
<Setter Property="Background" Value="Transparent" />
</Style>
不,您需要将TextBlock包装在边框中。例如:
<Border BorderThickness="1" BorderBrush="Black">
<TextBlock ... />
</Border>
当然,你也可以设置这些属性(BorderThickness
,BorderBrush
)通过样式以及:
<Style x:Key="notCalledBorder" TargetType="{x:Type Border}">
<Setter Property="BorderThickness" Value="1" />
<Setter Property="BorderBrush" Value="Black" />
</Style>
<Border Style="{StaticResource notCalledBorder}">
<TextBlock ... />
</Border>
使用文本框,而不是更换TextBlock的。 – 2016-04-15 03:24:01