我正在用自定义控件的OnRender
方法绘制一条垂直线。我应用GuidelineSet
,以使该行与物理设备像素对齐。然而,线条仍显得模糊,放大该线条可显示已应用了抗锯齿。我在这里做什么错了?
protected override void OnRender(DrawingContext dc)
{
Pen axisPen = new Pen(Brushes.Black, 1);
if (axisPen.CanFreeze)
axisPen.Freeze();
double lineLength = RenderSize.Height + 1;
double thick = axisPen.Thickness * 0.5;
GuidelineSet guidelines = new GuidelineSet();
guidelines.GuidelinesX.Add(thick);
dc.PushGuidelineSet(guidelines);
dc.DrawLine(axisPen, new Point(0, 0), new Point(0, lineLength));
dc.Pop();
}