Relative Content

Tag Archive for c#androidmaui

MAUI: how to dynamically add Views to Page?

The problem I face is that I want to add Views (Entry, Button, Label etc…) dynamically into a Page, meaning that I don’t know how many of each of them are to be displayed so I can’t code them in directly into Xaml. I was thinking about creating an ObservableCollection list of Views in my viewmodel, add the views into the list and somehow bind them to a CollectionView in the xaml file to dynamically display each of them. But That did not work out (the code i tried):

MAUI: how to dynamically add Views to Page?

The problem I face is that I want to add Views (Entry, Button, Label etc…) dynamically into a Page, meaning that I don’t know how many of each of them are to be displayed so I can’t code them in directly into Xaml. I was thinking about creating an ObservableCollection list of Views in my viewmodel, add the views into the list and somehow bind them to a CollectionView in the xaml file to dynamically display each of them. But That did not work out (the code i tried):

TargetInvocationException Thrown when Attempting to Load Text File in Android App

I’m writing a .NET MAUI app that loads Bible verses from a text file. Works fine when running on Windows, but the text file doesn’t appear when running the app in the Android Emulator, even though I have the text file’s Copy to output directory option set to Copy always. Instead, once the build finishes I get a TargetInvocationException because the file doesn’t appear in the App Data Directory. How do I make sure the file is in the right place when running the app on Android?

Users can’t enable the reminder for the app

In my NET8 MAUI apps, I want to send a local notification every day to remind the user to use the app. For that, I’m using the component Plugin.LocalNotification. For Android, in the AndroidManifest.xml, I added those lines