how to create a background in vs 2022 Xaml?

Pagina: 1
Acties:
  • 470 views

Vraag


Acties:
  • 0 Henk 'm!

  • Abbsy
  • Registratie: Oktober 2023
  • Laatst online: 18-10-2023
Hi,

I am completely new to programming. I installed visual studio 2022 and I am following the video's for beginners that the program gives. So far that goes well but now I am making the "note app" from the video, I get ideas of things I want to try and learn myself. One of those things is making a background, not just a color but a picture of my own that I made with photoshop. I would like it to be the whole background, not just a part of a grid.


I looked up several tutorials and some fora but nothing of the codes is working. And since it is al new, it is difficult to figure out why it doesn't working.

one of the codes I tried:

<Grid>
<Image
x:Name="backgroundImage"
Source="image_source.png"
Aspect="AspectFill"
HorizontalOptions="Start"/>
</Grid>

I added my picture in the folder (that was explained in the movie so that should have been correct) and I changed the name in de code to the name of my picture.

and than they said to put the next in the code behind

protected override void OnSizeAllocated (double pageWidth, double pageHeight) {
base.OnSizeAllocated(pageWidth, pageHeight);
const double aspectRatio = 1600 / 1441.0; // Aspect ratio of the original image
backgroundImage.WidthRequest = Math.Max(pageHeight * aspectRatio, pageWidth);
}

So when I put in the first part, I could just debug with no errors but there did not came any picture as background. When I added the second part I got errors but now I wanted do take the same steps again to show you the errors, they are gone. It was something like "onsizeallocated" did not excisted.

I tried some other video's but haven't find a place where they can explain me how to work with background images for an android app.

I think I need to define some things or be specific on the location or something like that but I don't really know what exactly.

So, is there someone how can explain to me how this works? How can I use an image as background for my app?

Thank you!

Alle reacties


Acties:
  • 0 Henk 'm!

  • RobIII
  • Registratie: December 2001
  • Laatst online: 20:12

RobIII

Admin Devschuur®

^ Romeinse Ⅲ ja!

This is a Dutch forum where we speak dutch ;)
Other than that, this is not how the Devschuur operates. Those questions pre-filled when you opem a new topic are there for a reason ;)
Mijn vraag
...

Relevante software en hardware die ik gebruik
...

Wat ik al gevonden of geprobeerd heb
...
If can, please open a new topic, in dutch, after reading our Quickstart and when you post code, please use code tags in our new topc ;) You can use english, but only if you can't speak dutch (then there's still Google Translate or other services that may help you with that...)

[ Voor 13% gewijzigd door RobIII op 18-10-2023 18:14 ]

There are only two hard problems in distributed systems: 2. Exactly-once delivery 1. Guaranteed order of messages 2. Exactly-once delivery.

Je eigen tweaker.me redirect

Over mij


Dit topic is gesloten.