FormattedText的波浪下划线

时间:2016-03-02 10:38:14

标签: c# wpf format

我想画一个波浪下划线允许FormattedText。 我设置了formattedtext.Set TextDecorations但是当调整字体wavylines错误。

我写道:

var geometry = new StreamGeometry();
using (var context = geometry.Open())
{
    context.BeginFigure(new Point(0.0, 1), false, false);
    context.PolyLineTo(new[] {
        new Point(1.5, 0),
        new Point(3, 3),
        new Point(4.5, 1.5),
        new Point(6, 0),
        new Point(7.5, 3),
        new Point(9, 1.5)
    }, true, true);
}

var brushPattern = new GeometryDrawing
{
    Pen = new System.Windows.Media.Pen(System.Windows.Media.Brushes.Black, 1),
    Geometry = geometry
};

var brush = new DrawingBrush(brushPattern)
{
    TileMode = TileMode.Tile,
    Viewport = new Rect(0, 0, 9, 4),
    ViewportUnits = BrushMappingMode.Absolute,
    Viewbox = new Rect(0, 0, 9, 4),
    ViewboxUnits = BrushMappingMode.Absolute,
    Stretch = Stretch.Fill
};
System.Windows.TextDecoration squiggly = new System.Windows.TextDecoration();
squiggly.Pen = new System.Windows.Media.Pen(brush, 1.2);

你能帮助我吗?

0 个答案:

没有答案