Images show up on other devices but not windows build

anandarus allen 0 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
     }
 };

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
4,105 questions
{count} votes

1 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.

    0 comments No comments

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.