带有虚线边框的richtextbox

时间:2012-04-24 13:33:20

标签: silverlight richtextbox border

如何制作带有虚线边框的richtextbox

我试过这样的事情:

    <Border Width="100" Height="100" Background="White" BorderThickness="1,1,1,1">
        <RichTextBox Name="richTextBox1" />
        <Border.BorderBrush>
            <LinearGradientBrush StartPoint="0,0" EndPoint="0,.1" SpreadMethod="Repeat" >
                <GradientStopCollection>
                    <GradientStop Color="Transparent" Offset="0" />
                    <GradientStop Color="Transparent" Offset="0.2" />
                    <GradientStop Color="Red" Offset="0.2" />
                    <GradientStop Color="Red" Offset="0.4" />

                    <GradientStop Color="Transparent" Offset="0.4" />
                    <GradientStop Color="Transparent" Offset="0.6" />
                    <GradientStop Color="Red" Offset="0.6" />
                    <GradientStop Color="Red" Offset="0.8" />
                    <GradientStop Color="Transparent" Offset="0.8" />
                    <GradientStop Color="Transparent" Offset="0.9" />
                    <GradientStop Color="Red" Offset="0.9" />
                    <GradientStop Color="Red" Offset="1" />


                </GradientStopCollection>
            </LinearGradientBrush>

        </Border.BorderBrush>
    </Border>

但这只适用于左/右或上/下

1 个答案:

答案 0 :(得分:1)

(抱歉我的英语不好)

试试这个:

<Grid Width="200" Height="80">
        <Rectangle Fill="Transparent" Stroke="Red" StrokeThickness="3"  StrokeDashArray="1 1"/>
        <RichTextBox BorderThickness="0" Margin="3"/>
</Grid>

有点像黑客,也许你可以创建一个样式,这样你也可以覆盖RichTextBox边框。