简体   繁体   中英

Highlighter InkCanvas

I have used IsHighlighter property of InkCanvas to create highlighter tool . In real life when we use highlighter it highlights on the top of our notebooks or books writing , but in InkCanvas i am not able to highlight on the top of Ink which i have previously drawn . I am creating application which have pen as well highlighter tool , now if i have to highlight some thing which i have drawin onto InkCanvas using pen highliter goes down to Ink .

检查此图像,其中我有笔以及荧光笔

here highlighter is highlighting bellow my pen's drawing.

Any solutions?

If you want to manipulate the ZOrder of strokes there is a workaround for that: Using multiple InkCanvases

I am a bit disappointed by this; I'd expect the ability to move strokes on top. I even tried to manipulate the order of the Strokes in the StrokeCollection but to no avail.

So I found a more intuitive way: just do not use the IsHighlighter property but instead make a DrawingAttributes object with a Transparent color:

private DrawingAttributes _highLighter =
    new DrawingAttributes { 
        Color = Color.FromArgb(128, 255, 255, 0),
        IsHighlighter = false, 
        Width = 20, Height = 20 
    };

The strokes with this color will be added on top just like a normal highlighter and when you switch back to a pen(cil) you will overwrite the highlights, just as in real life.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM