是否可以在文本块中添加边框。我需要将其添加到以下代码的setter属性中:
<Style x:Key="notCalled" TargetType="{x:Type TextBlock}">
<Setter Property="Margin" Value="2,2,2,2" />
<Setter Property="Background" Value="Transparent" />
</Style>
Answers:
不,您需要将TextBlock包裹在Border中。例:
<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>