Need help with MAUI's XAML Pages
Hey guys! so I have created MAUI page but I used to run it only on windows. and it look good enough for my expectations But when I run it on Android I thought it would be responsive and shrink to fit android screen but instead something weird just appeared π
.
56 Replies
Here is how it looked on android how to make it a smaller version of windows
Here is my code, I am new to MAUI and bad in front end developing so excuse me if you see a lot of strange things in the code π
.
Android and windows are 2 complete different experience for UI
My advice is make pages specific for windows and pages specific to Android
Otherwise u will have to write all your XAML taking into consideration resizing
and it would need to be able to morph as it reaches say tablet size , mobile size etc
GitHub
maui-samples/8.0/Apps/WeatherTwentyOne/src/WeatherTwentyOne at main...
Samples for .NET Multi-Platform App UI (.NET MAUI) - dotnet/maui-samples
you can look at this example
Got it
I have another problem suddenly hot reload stopped working
when I created new MAUI project it works on it, but the one that contain the pages above it doesn't work on it
have u tried closing the emulator and running all again
the above app, this is what it looks on each
Yup
so it should give u an idea on how to work it out
Perfect I'll give it a look
is your xaml building properly?
Yea
it gives an error regarding hot reload lemme get it for you
then I dont know sorry, hot reload only stops working for me if I do some complex xaml modification it can't follow up and after restarting the build it works again
if there is an error that might help
it says CSS Hot Reload ignoring https://mk6lhkhk-7219.inc1.devtunnels.ms/swagger/swagger-ui.css because it was inaccessible or had more than 5000 rules. is it related?
are you hosting blazor on maui?
MAUI
are you using a webview?
No, listview
where is css coming from then... im confused
if you're acessing an API u wouldn't get css
If i want to test Listview without getting data using api, should I create like a model view then create objects of the model and store them in a list ?
cause when I created another MAUI project the hot reload is working there and I want to use it to start building the android page
I think you're accessing the wrong api url
that's why your getting swagger related files
wrong url
right url
if u have "swagger" in your api urls its wrong
when I run the project it lauches browser with swagger
should I turn it off ?
those page are just for you to via and test the api
there is nothing wrong with that, that is just so u can visualize and test your api
it also provides u with all the endpoints
nothing in my endpoints contains swagger
can you show me some of the code where you do the httpclient to get the results?
for example
http://localhost:5213/WeatherForecast
this would be my endpoint if you're looking at it from swagger
I used _baseAddress this way before I use dev tunnels that why it exists
that looks fine
oh
mmm could it be the authorization page?
I dont have an authorization page yet
I guess I will just code the page in the project that has hot reload working
after finishing I'll copy paste it in my project
Thank you for you help, much appreciated ππΎ
if u access https://mk6lhkhk-7219.inc1.devtunnels.ms in your browser does it pop something asking if u wantto continue
but either way to answer your relevant question
the API will give u json
you would deserialize that JSON insto a class
i.e.:
so you can certainly use that to populate your listview
without relying on the api for testing
Now no, but after I created the tunnel for the first time it did yes
so result would be a List<PointOfSales>
I see
that is just a rough example
but could be like with out the class that contain httpClient
wdym?
Like in the page.xaml.cs
I just create objects and store them in a list
without sending a request or something
yes you can, u already have the class above
you can simple create a List<PointOfSales> and fill it with dummy data
so it would be
pointOfSales p = new PointOfSale (2, fdsfds, 2, 2, fdsf,)
List<PointOfSales> p = new List<PointOfSales>
List<PointOfSales>.add(p)
then do Listview.ItemSource = p
is this right?
u cannot use p like that
but yes something like that
Yea yours is much betterπ
got it now, thank you again
but this error is very strange and should not be happening on MAUI, it shouldn't be sending css files to u...
np
idk, everytime I want to develop a MAUI page I just remeber that hot reload is not working and just stall.
been a nightmare ..
BTW do you have any suggestions on authenticating users using google?
yeah that is a very weird error to happen since its not at all related to maui
but your api
Web Authenticator - .NET MAUI
Learn how to use the .NET MAUI IWebAuthenticator interface, which lets you start browser-based authentication flows, which listen for a callback to the app.
I found this: https://learn.microsoft.com/en-us/dotnet/maui/platform-integration/communication/authentication?view=net-maui-8.0&tabs=windows
Web Authenticator - .NET MAUI
Learn how to use the .NET MAUI IWebAuthenticator interface, which lets you start browser-based authentication flows, which listen for a callback to the app.
but it says its not working for windows ATM
where? I never tried it on windows I only use MAUI for android and iOS
ah I see but it says right under
how to do it thou
if that does not work then u would have to do it differently on windows
then u would on mobile
by starting a browser or something when it gives u the redirection url
oauth is pretty confusing if its your first time doing it, I would worry about it when u get there
It is my first time .. and it already got my anxiety level very high π
Felt a little proud of my self after doing MAUI and webAPI then after doing a little search on how google authenticating works and seeing how complicated it is, feels sad.
its easy once u get it, but yes its complex
because it uses your api as a callback, to reach out to google to get a url that ur app will launch for the use to safely auth to their page
which then redirects back to your api with tokens and what not
that u then need to redirect back into your app
Turned out this error is not related to the MAUI project. I ran the webAPI alone without the MAUI project and it gave the error.