0

I’ve developed a cross-platform Sudoku app for Android and Windows using MAUI (.NET 9) and Shell, following the MVVM design pattern. The UI is defined in XAML using StackLayout to organize visual elements. Beyond standard gameplay, the app guides users in learning and applying advanced Chain techniques and more. I'm now looking to enhance it by drawing straight lines between cell candidates to visually represent Chain Links.

After many attempts, I’ve managed to retrieve the coordinates of two cell's candidates using drag-and-drop gestures. However, I’m still unable to draw a straight line between them—possibly due to a scaling issue among coordinate systems. Any suggestions on how to achieve this would be greatly appreciated, and a code sample would be even better.

2
  • 1
    Please show us what you’ve tried and explain the problem you’re having with it Commented Jul 25 at 1:32
  • I had been using Line and Polyline for drawing and relying on drag-and-drop gestures to retrieve visual element coordinates. Stephen's idea offers a fresh approach to this. Commented Jul 25 at 12:48

1 Answer 1

0

Use a combination of:

    1. An outer Grid so that children components will mash up
    1. Use Path to draw vector geometry

Here's a simple XAML to get you started:

<Grid BackgroundColor="SkyBlue" HeightRequest="200" WidthRequest="200">
    <Path Data="M 50 50 L 150 50 L 50 150 L 150 150" Stroke="Red" />
    <Grid Padding="25" ColumnDefinitions="*,*" ColumnSpacing="50"
                       RowDefinitions="*,*" RowSpacing="50">
        <Button Grid.Row="0" Grid.Column="0" Text="1" />
        <Button Grid.Row="0" Grid.Column="1" Text="2" />
        <Button Grid.Row="1" Grid.Column="0" Text="3" />
        <Button Grid.Row="1" Grid.Column="1" Text="4" />
    </Grid>
</Grid>

StraightLine.png

References:

Sign up to request clarification or add additional context in comments.

1 Comment

Excellent — the outer grid approach works perfectly for my case. I really appreciate the code snippet!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.