Repository: PixiEditor/PixiEditor
File: src/PixiEditor/Views/Overlays/GridLinesOverlay.cs (C#)

Code before:
        get => GetValue(PixelWidthProperty);
        set => SetValue(PixelWidthProperty, value);
    }

    public int Columns
    {
        get => GetValue(ColumnsProperty);
        set => SetValue(ColumnsProperty, value);
    }

    public int Rows
    {
        get => GetValue(RowsProperty);
        set => SetValue(RowsProperty, value);
    }

    private const float PenWidth = 0.8f;
    private Paint pen1 = new Paint() { Color = Colors.Black, StrokeWidth = PenWidth, IsAntiAliased = true, Style = PaintStyle.Stroke };
    private Paint pen2 = new Paint() { Color = Colors.White, StrokeWidth = PenWidth, IsAntiAliased = true, Style = PaintStyle.Stroke };
    private ThresholdVisibilityConverter visibilityConverter = new(){ Threshold = 10 };

    static GridLinesOverlay()
    {
        IsVisibleProperty.Changed.Subscribe(OnIsVisibleChanged);
    }

    public GridLinesOverlay()
    {
        IsHitTestVisible = false;
    }

    public override bool CanRender()
    {
        return visibilityConverter.Check(ZoomScale);
    }

    public override void RenderOverlay(Canvas context, RectD canvasBounds)
    {
        // Draw lines in vertical and horizontal directions, size should be relative to the scale

        double width = PixelWidth;
        double height = PixelHeight;

        double columnWidth = width / Columns;
        double rowHeight = height / Rows;

        pen1.StrokeWidth = (float)ReciprocalConverter.Convert(ZoomScale);
        pen2.StrokeWidth = (float)ReciprocalConverter.Convert(ZoomScale, 1.2);

        for (int i = 0; i < Columns; i++)
        {

Review comment (suggestion):
fyi you can also use 
```cs
 static GridLinesOverlay()
    {
        IsVisibleProperty.Changed.Subscribe(OnIsVisibleChanged);
        AffectsOverlayRender(GridXSizeProperty, GridYSizeProperty);
    }
```

Code after:
        get => GetValue(PixelWidthProperty);
        set => SetValue(PixelWidthProperty, value);
    }

    public double GridXSize
    {
        get => GetValue(GridXSizeProperty);
        set => SetValue(GridXSizeProperty, value);
    }

    public double GridYSize
    {
        get => GetValue(GridYSizeProperty);
        set => SetValue(GridYSizeProperty, value);
    }

    private const float PenWidth = 0.8f;
    private Paint pen1 = new Paint() { Color = Colors.Black, StrokeWidth = PenWidth, IsAntiAliased = true, Style = PaintStyle.Stroke };
    private Paint pen2 = new Paint() { Color = Colors.White, StrokeWidth = PenWidth, IsAntiAliased = true, Style = PaintStyle.Stroke };
    private ThresholdVisibilityConverter visibilityConverter = new(){ Threshold = 10 };

    static GridLinesOverlay()
    {
        IsVisibleProperty.Changed.Subscribe(OnIsVisibleChanged);
        GridXSizeProperty.Changed.Subscribe(OnNumberChanged);
        GridYSizeProperty.Changed.Subscribe(OnNumberChanged);
    }

    public GridLinesOverlay()
    {
        IsHitTestVisible = false;
    }

    public override bool CanRender()
    {
        return visibilityConverter.Check(ZoomScale * Math.Min(GridXSize, GridYSize));
    }

    public override void RenderOverlay(Canvas context, RectD canvasBounds)
    {
        // Draw lines in vertical and horizontal directions, size should be relative to the scale

        double width = PixelWidth;
        double height = PixelHeight;

        double columnWidth = GridXSize;
        double rowHeight = GridYSize;

        pen1.StrokeWidth = (float)ReciprocalConverter.Convert(ZoomScale);
        pen2.StrokeWidth = (float)ReciprocalConverter.Convert(ZoomScale, 1.2);