c# - 在wpf中绘制双线

标签 c# wpf styles line

我需要在 wpf 中使用笔划破折号数组或类似的东西绘制这样的线条。这应该代表单线对象而不是两条平行线对象。

enter image description here

最佳答案

您可以通过为您的Stroke 使用LinearGradientBrush 来使这种垂直线加倍。像这样:

<Line.Stroke>
    <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
        <LinearGradientBrush.GradientStops>
            <GradientStopCollection>
                <GradientStop Color="Black" Offset="0.2"/>
                <GradientStop Color="Transparent" Offset="0.201"/>
                <GradientStop Color="Transparent" Offset="0.799"/>
                <GradientStop Color="Black" Offset="0.8"/>
            </GradientStopCollection>
        </LinearGradientBrush.GradientStops>
    </LinearGradientBrush>
</Line.Stroke>

您还应该将线条的 HeightStrokeThickness 设置为相同的值,以确保显示整个渐变。

关于c# - 在wpf中绘制双线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23146164/

相关文章:

c# - ASP.NET MVC 中的后台线程 'job-queue'

c# - 在 Delphi 2007 中使用 SDK BSOD 但在 C# 中工作的应用程序

c# - 如何从 ViewModel 创建和显示弹出窗口

css - 如何更改动态创建的输入字段的样式?

html - 增加 UL 列表元素符号的宽度

c# - Google 饼图图例类型标记显示百分比

c# - 从 Sql Server 迁移到 MySQL 后,EntityFramework 执行查询时出现问题

css:在悬停之前设置所有元素的样式

c# - 在 xaml 中声明数组的数组

c# - 单击按钮时禁用选中的复选框