Images show up on other devices but not windows build

anandarus allen 20 Reputation points
2025-04-25T18:25:52.6066667+00:00

Hi,

I am building a .net maui application my .png's show up on android and android emulatorsScreenshot_20250425_131642

But I am unable to get the same image on windows build, or any image for that matter of fact

Screenshot-2

Here is the code that use.

 var  var image = new Image()
 {
     Source = source,
     Aspect = Aspect.Fill,
     WidthRequest = 100,
     HeightRequest = 100,    
     VerticalOptions = LayoutOptions.Center
     
 };
 AbsoluteLayout.SetLayoutBounds(image, new Rect(0, 0, 1, 1));
 AbsoluteLayout.SetLayoutFlags(image, AbsoluteLayoutFlags.All);
 // Button 1
 var playButton = new ImageButton
 {
     Source = "MainMenuBts/play.png",
     BackgroundColor = Colors.Transparent,
     WidthRequest = scaleImages.Scaling(),
     HeightRequest = scaleImages.Scaling(),
 };
 AbsoluteLayout.SetLayoutBounds(playButton, new Rect(posA, posA1, playButton.WidthRequest, playButton.HeightRequest));
 AbsoluteLayout.SetLayoutFlags(playButton, AbsoluteLayoutFlags.PositionProportional);
 Content = new AbsoluteLayout
 {
     Children =
     {
         image,
         title,
         playButton
     }
 };

Developer technologies | .NET | .NET MAUI
{count} votes

Accepted answer
  1. Saideep Anchuri 9,500 Reputation points Moderator
    2025-05-26T07:05:39.5233333+00:00

    Hi anandarus allen

    I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to accept the answer.

    Ask: Images show up on other devices but not windows build

    Solution: The issue is resolved. That you fixed it by flattening out the images, which is just removing them from the subfolders. Android takes the subfolders but not Windows.

    If I missed anything please let me know and I'd be happy to add it to my answer, or feel free to comment below with any additional information.

    If you have any other questions, please let me know. Thank you again for your time and patience throughout this issue.

     

    Please don’t forget to Accept Answer and Yes for "was this answer helpful" wherever the information provided helps you, this can be beneficial to other community members.

    Thank You.


1 additional answer

Sort by: Most helpful
  1. Kshitij Wankhade 0 Reputation points
    2025-05-10T10:23:10.62+00:00

    var playButton = new ImageButton

    {

    Source = ImageSource.FromFile("Images/MainMenuBts/play.png"), // Or try .FromResource for embedded resources
    
    BackgroundColor = Colors.Transparent,
    
    WidthRequest = scaleImages.Scaling(),
    
    HeightRequest = scaleImages.Scaling(),
    

    };

    By ensuring that images are correctly placed in the Resources\Images folder, confirming the correct usage of ImageSource, and considering platform-specific paths, you should be able to make the images visible on Windows. If the issue persists, try debugging the image paths and verify if any platform-specific behavior is affecting the image loading.


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.