Maui: Image not displayed

Eduard Kaufmann 231 Reputation points
2025-02-17T14:55:33.3466667+00:00

Hi, in the process of migrating the data input from 'data.cs' to 'data.json' I'm stuck ... or, as a senior hobby developer just not experienced enough. Thanks for your time, help and advice.

On GIT I have two sites (both are public)

1st App RandoCS: which runs ok using .cs files as Data input github.com/edikaufmann/randoCS

2nd App RandoJson: where I use .json files as input github.com/edikaufmann/randojson:

In RandoJson../randopro/Views/MainPage.xaml:

when running it and click 'get randos' I do NOT see the 'image' and 'labels'. However, when clicking 'get closest' I receive the correct result i.e the .json files are read correctly. When debugging the App I see that the correct Image(s) are found!

What stupid thing do I miss not seeing the 'image' on the MainPage.xaml?

Thanks again, ed

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,447 questions
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,939 questions
0 comments No comments
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 48,581 Reputation points Microsoft Vendor
    2025-02-18T03:18:08.21+00:00

    Hello,

    After investigation, the problem is not caused by MVVM data binding and JSON deserialization. The reason why the Image and Label are not displayed is that a non-existent Style is used in the XAML page.

    <Frame HeightRequest="125" Style="{StaticResource CardView}">

    Since CardView is not defined, the outermost Frame is a wrapper layer with a width and height of 0, which causes the data to not be displayed as expected.

    Workaround: Remove this Style.

    <Frame HeightRequest="125">

    Update:

    This is a problem caused by static resource references. The LargeLabel in <Label Style="{StaticResource LargeLabel}" Text="{Binding Name}" /> is not defined and therefore cannot be rendered.

    For resource references in the Maui project please refer to this document.

    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.

1 additional answer

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

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.