Runtime Error in Net Maui Graphics

Yusuf 791 Reputation points
2022-08-02T00:15:56.257+00:00

I am trying to apply Maui Graphics but it's not as easy as Skiasharp and System.Drawing, because the drawing class is separate, and my skills in object programming are low.

I've been trying for days to create the simplest example that displays dynamic data.

Please help me create the simplest app that displays data in Maui graphics.

my code
https://github.com/devenv2/MauiApp6

Thank you in advance.

@Leomaris Reyes @Matthew Leibowitz @James Montemagno

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,412 questions
0 comments No comments
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 42,001 Reputation points Microsoft Vendor
    2022-08-02T05:19:45.43+00:00

    Hello,

    I've tested your project and made it display dynamic data from the firebase, you could refer to the following code:

       public void Draw(ICanvas canvas, RectF dirtyRect)  
       {  
           canvas.FontColor = Colors.Blue;  
           canvas.FontSize = 18;  
           canvas.Font = Font.Default;  
           FirebaseHelper firebaseHelper = new FirebaseHelper();  
           var books = Task.Run(() => firebaseHelper.GetAllBooksAsync()).Result;  
           int i = 0;  
           foreach (var book in books)  
           {  
               i++;  
               canvas.DrawString(book.Title, 100, 50 * i, HorizontalAlignment.Center);  
           }  
       }  
    

    If you want to learn more about GraphicsView, you could refer to this official demo: GraphicsViewDemos.

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.