0

如何制作带有虚线边框的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>

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

4

1 回答 1

1

(对不起,我的英语不好)

尝试这个:

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

有点 hack,也许你可以用它创建一个样式,这样你也可以覆盖 RichTextBox 边框。

于 2012-04-24T18:15:19.373 回答