5

I am trying to put a background image, so far I have this code:

<Grid.Background>
    <ImageBrush ImageSource="ms-appx:///Assets/Windows-10-Hero-Ninja-Cat-1024x576-03a71eed2a427425.jpg" Stretch="UniformToFill"/>
</Grid.Background>

Which appears this way on UWP on Windows 10:

UWP on Windows 10

But when I Build the WASM or Android, the Background image does not appear.

Edge

enter image description here

The file property is set Build action: Content, Copy to output directory: Do not copy.

enter image description here

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Tony
  • 16,527
  • 15
  • 80
  • 134

2 Answers2

6

Uno's WASM target is still experimental and some features are not available yet. The only yet implemented background brush is SolidColorBrush.

It's implemented for iOS (source code here), but not Android.

Since you're already in a <Grid>, you can simply put your image as first element:

  <Grid>
    <Image Source="ms-appx:///Assets/Windows-10-Hero-Ninja-Cat-1024x576-03a71eed2a427425.jpg" Stretch="UniformToFill" />
    [... put your other controls here]
  </Grid>
Carl de Billy
  • 941
  • 6
  • 13
1

In case you need to use different background approaches for each platform use xaml conditional prefixes.

https://platform.uno/docs/articles/platform-specific-xaml.html#xaml-conditional-prefixes

You can use <wasm:Image ... />

At the end of the day you can have the same result with flexible markup.

Murilo Maciel Curti
  • 2,677
  • 1
  • 21
  • 26