dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.28k stars 1.76k forks source link

Add support for Background image with ImageBrush #12928

Open ziaulhasanhamim opened 1 year ago

ziaulhasanhamim commented 1 year ago

Description

There is no proper elegant way of setting background images for different layouts. Like there are ways but it's very tricky. In WPF you can just use an ImageBrush to add background Images.

<StackPanel>
     <StackPanel.Background>
           <ImageBrush ImageSource="path" />
     </StackPanel.Background>
</StackPanel> 

This can be helpful feature

Public API Changes

Adding a new Control for Images in the Background

ghost commented 1 year ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

ewerspej commented 1 year ago

As a workaround for now, you can wrap your Layout with a Grid, like this:

<Grid>

    <Image
        Source="someimage.png"
        Aspect="AspectFill"
        VerticalOptions="Fill"
        HorizontalOptions="Fill" />

    <VerticalStackLayout
        VerticalOptions="Fill"
        HorizontalOptions="Fill">

        <Label Text="Label inside of StackLayout with an image in the background" />

    </VerticalStackLayout>

</Grid>

I know, it's not ideal, but as long as there is no ImageBrush or BackgroundImage available, it will have to do.

sebastianroibu commented 5 months ago

Is it another hack because MAUI is not old/smart/ready enough?

DanCarte1 commented 5 months ago

Yes, Maui is not ready!

I tried this. No matter what I do I get my image with a white background. If I set a background color, I mask the image.

The only solution that I can think of is to create an image about the size of most phones and hope that it works ok.

DanCarte1 commented 5 months ago

OK... If you set the bacckground color in the content page and then uses a nested grid to hold the image it works.