I am a Senior software engineer at DataArt, Microsoft MVP, and maintainer of .NET MAUI Community Toolkit.
๐ซ You can reach me at https://vladislavantonyuk.github.io
.NET MAUI Samples
Home Page: https://vladislavantonyuk.azurewebsites.net/articles?categoryName=.NET%20MAUI/Xamarin
License: MIT License
I am a Senior software engineer at DataArt, Microsoft MVP, and maintainer of .NET MAUI Community Toolkit.
๐ซ You can reach me at https://vladislavantonyuk.github.io
Do you know if the iOS implementation is limited to where if you have a scroll view as part of your view you are limited to the height of the device? IE. scroll view won't work in iOS? I have it working on android on emulator and device and scroll but iOS appears to be limited to the height of the screen.
The existing sqlite database file can not be found with MauiAsset build action.
The file is setting as follows,
Construct a SQLiteConnection
will create a new file. The origin file can be found by FileSystem.OpenAppPackageFileAsync
internal static class Database
{
string databasePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "database.db");
public static SQLiteConnection CreateConnection()
{
return new SQLiteConnection(databasePath);
}
}
KanbanBoard project file has both : EntityFrameworkCore and SQLitePCLRaw entries. I dont know if this was on purpose with the intention of requiring the user to delete the SQLitePCLRaw entries because the project wont compile and run otherwise. The project files themselves reference Microsoft.EntityFrameworkCore.
Hi,
I have downloaded the whole solution and it works on Windows but when I run on the Android 33 emulator, I get this error:
System.IO.FileNotFoundException: 'Could not load file or assembly 'AuthServices, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.'
your code doesnt work for me :( both in my own project, and in your Maui examples, the following error comes up "Error MSB6006: "ditto" was terminated with code 1.". Do you have any suggestions?
Any image without a background color specified will be displayed as white which is same as the page background.
As a result, you cannot see these images displayed so nothing appears when the + is clicked.
Hi,
I'd like to have a TabView header that looks like the TabbedPage header (icon+title ; tab header fills the whole width of the page).
So, two questions about the MauiTabView IndicatorView+CarouselView example:
Thanks
Hi! I have followed your guide about localization in .NET MAUI, but I'm facing an issue on iOS devices. I attempted to implement localization in a new project, following your guide step by step, and also downloaded your sample code from Github. While the localization worked as expected on Android devices, I encountered an issue on iOS devices where the localization did not change.
I was wondering if anyone else has experienced this issue, and if there are any known solutions or workarounds. Thank you for your help!
I hope that it should work like React beautiful D&D. For example: When we drag an item over a droppable list then other items in that dropable list should move and leave space for this new item.
I'm running into two issues trying to get the bottomdrawer example code. First, it seems like Android.Resources.Content.Id
doesn't exist, at least not in .net 7.
I've replaced it with Resource.Id.content
, but I'm not sure 100% that's correct.
Second, is I am getting an exception with getTheme() at runtime when the bottom sheet is trying to open
Message=Attempt to invoke virtual method 'android.content.res.Resources$Theme android.content.Context.getTheme()' on a null object reference```
looking for version of KanbanBoard on its own that will build and run on windows and mac - cannot get large project to build
do you have working version of KanbanBoard on its own that actually builds and runs first time
It would be a good a idea to make a scroll to the next column when we get to the edge. But I have no idea how to do that, any idea?
doesn't run using vs.net 2022 - keeps complaining card table doesn't exist
I saw and tried your code. The problem is when you need to navigate to a ContentPage that doesn't need to show the Shell TabBar. The customTabBar hides it self but the central button remains there.
i have used your SQLite project and it has been successfully run. Thanks. I have another question to ask. Can Maui connect to the Firebird database?
I can see the bluetooth permission is there.
When I ran this similar (outdated) code - it works fine .
https://github.com/TimoKinnunen/MauiXAMLBluetoothLE/blob/6c328d37ac5df6612dc288567f97a6b668da3ce0/MauiXAMLBluetoothLE/Services/BluetoothLEService.cs
seems like you need to request permission like this (specifically for android/ other platforms - doesn't matter)
https://github.com/TimoKinnunen/MauiXAMLBluetoothLE/blob/6c328d37ac5df6612dc288567f97a6b668da3ce0/MauiXAMLBluetoothLE/Services/BluetoothLEService.cs
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" package="com.vladislavantonyuk.mauibluetooth" android:versionName="1.0">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
<uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" />
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true" android:name="crc64d8fabeac2e8e5729.MainApplication" android:label="MauiBluetooth" android:debuggable="true" android:extractNativeLibs="true">
<activity android:configChanges="density|orientation|smallestScreenSize|screenLayout|screenSize|uiMode" android:theme="@style/Maui.SplashTheme" android:name="crc64d8fabeac2e8e5729.MainActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:configChanges="orientation|screenSize" android:exported="true" android:name="crc6468b6408a11370c2f.WebAuthenticatorIntermediateActivity" />
<provider android:authorities="com.vladislavantonyuk.mauibluetooth.fileProvider" android:exported="false" android:grantUriPermissions="true" android:name="microsoft.maui.essentials.fileProvider">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/microsoft_maui_essentials_fileprovider_file_paths" />
</provider>
<receiver android:enabled="true" android:exported="false" android:label="Essentials Connectivity Broadcast Receiver" android:name="crc64e53d2f592022988e.ConnectivityBroadcastReceiver" />
<activity android:configChanges="orientation|screenSize" android:exported="true" android:name="crc64ba438d8f48cf7e75.IntermediateActivity" />
<receiver android:enabled="true" android:exported="false" android:label="Essentials Battery Broadcast Receiver" android:name="crc640a8d9a12ddbf2cf2.BatteryBroadcastReceiver" />
<receiver android:enabled="true" android:exported="false" android:label="Essentials Energy Saver Broadcast Receiver" android:name="crc640a8d9a12ddbf2cf2.EnergySaverBroadcastReceiver" />
<service android:name="crc64396a3fe5f8138e3f.KeepAliveService" />
<provider android:name="mono.MonoRuntimeProvider" android:exported="false" android:initOrder="1999999999" android:authorities="com.vladislavantonyuk.mauibluetooth.mono.MonoRuntimeProvider.__mono_init__" />
</application>
<!--suppress UsesMinSdkAttributes-->
<uses-sdk android:minSdkVersion="21" />
</manifest>
I implemented the FAB using the pattern you suggested in your post. In the image you can see the FAB with a background of green. The collectionview behind it has a tapgesturerecognizer on each item that pulls up the bottomsheet with details of each book. The problem with the FAB is that the collectionview tap is recognized vs the button in the expander view content. Any thoughts on how to resolve that?
Thanks
Using the Android version of MauiMaps, press "Add new pin" a couple of times. Then press "Remove last pin" and no pins are removed from displayed map.
hi
where is add db in maui?
in resources or in each paltfrom?
i am currently trying to implement your Markup Extention for translating strings via the AppResources, as you explained it here.
I can successfully use the Markup Extention in that way: EigenschaftName="{xamlExt:Translate String10423}"
But now i got a Problem. The control where i use that code, is within a DataTemplate. That template is within a CollectionView.
You already got it, i think. I need to Bind the Key of the string to the underlying object.
How do i do this? I made a screenshot here:
(Just have a look at row 39, where i need the Binding)
MauiTaskListApp crashes after splash screen in release mode on device
Hello,
I am trying to run the example on windows and I am getting the following error:
{Microsoft.UI.Xaml.UnhandledExceptionEventArgs}
Exception: {"A cycle occurred while laying out the GUI."}
Handled: false
Message: "Layout cycle detected. Layout could not complete."
I attach an image of the dependencies I am using. I don't know if anything extra needs to be done to be able to run the example.
Thank you!
When I attempt to remove pin on MauiMaps Android, removed pin still appears on map.
I noticed in Android CustomMapHandler Markers is never is set to anything.
I added the following lines to AddPins() after the check for null at start of methos:
if (Markers == null) Markers = new List<Marker>();
Then the pin gets removed from map as expected.
Another issue I see and dont understand is the Action finished method for ImageSource.LoadImage appears to be called 4 times for each ImageSource.LoadImage () request. I examined Markers after adding a pin and there are 4 new Marker entries for an added pin.
I am using the latest version on the repository and Microsoft Visual Studio Community 2022 (64-bit) - Preview
Version 17.6.0 Preview 2.0
Error CS1061 'CustomPin' does not contain a definition for 'AddAnnotation' and no accessible extension method 'AddAnnotation' accepting a first argument of type 'CustomPin' could be found (are you missing a using directive or an assembly reference?)
The repro project:
https://github.com/HobDev/CustomPinSample
I tested the BottomSheet on Android, but I cannot drag the sheet over the "open bottom sheet" button. Is that not possible? Or is there any parameter setting missing?
I used an API32 emulator.
MauiCursor library is working well done. But more developer need hiding cursor for app which is running with a touchscreen device.
Can i hide cursor or show custom empty cursor?
Note: i try this topic's solution https://social.msdn.microsoft.com/Forums/en-US/14001796-bcd5-4b9d-9d7e-13bc6ba59d2d/uwp-how-to-set-a-pointer-cursor-as-a-circle-instead-of-a-window-default-cursor?forum=wpdevelop. But it didn't run correctly.
The call to googleMap.Clear() in OnMapReady has a side affect of clearing anything else added to the map. If you added any shapes or polylines, they will get removed after Clear() is called.
I have tried this but no luck!!
var bottomSheetDialog = new BottomSheetDialog(Platform.CurrentActivity?.Window?.DecorView.FindViewById(Android.Resource.Id.Content)?.Context ?? throw new InvalidOperationException("Context is null"));
bottomSheetDialog.SetContentView(bottomSheetContent.ToPlatform(page.Handler?.MauiContext ?? throw new Exception("MauiContext is null")));
// Allow touches on the underlying page
bottomSheetDialog.Window?.ClearFlags(WindowManagerFlags.NotTouchable);
bottomSheetDialog.Window?.ClearFlags(WindowManagerFlags.DimBehind);
bottomSheetDialog.Window?.ClearFlags(WindowManagerFlags.NotFocusable);
// Set the behavior of the bottom sheet
bottomSheetDialog.Behavior.Hideable = true;
bottomSheetDialog.Behavior.FitToContents = true;
bottomSheetDialog.SetCancelable(true);
bottomSheetDialog.Behavior.HalfExpandedRatio = 0.5f;
bottomSheetDialog.Show();
return bottomSheetDialog;
on iOS is working as intended when using medium or large detents!
it does not work (Save&Read) aswell it cant create a new folder or display right paths
Hi thanks for the good work.
btw, Can you advise or post some sample code about Implementing Bluetooth (discover, read) in .NET MAUI Android?
highly appreciated your help on this.
Thanks
{System.Threading.Tasks.TaskCanceledException: A task was canceled.
at Microsoft.Maui.Controls.StreamImageSource.Microsoft.Maui.IStreamImageSource.GetStreamAsync(CancellationToken userToken) in D:\a_work\1\s\src\Controls\src\Core\StreamImageSource.cs:line 48
at Microsoft.Maui.Controls.Compatibility.Platform.Android.ImageLoaderSourceHandler.LoadImageAsync(ImageSource imagesource, Context context, CancellationToken cancelationToken) in D:\a_work\1\s\src\Compatibility\Core\src\Android\Renderers\ImageLoaderSourceHandler.cs:line 19
at CustomizedMap.Platforms.Android.CustomMapHandler.AddPins(IEnumerable`1 mapPins) in {folder path here}\Platforms\Android\CustomMapHandler.cs:line 97}
The repro project is here:
https://github.com/HobDev/CustomPinSample
Setting the Popup.Color property on iOS to Transparent doesnt make the Popup Background transparent it stays gray. Appersntly that is because iOS handles page backgrounds differently than Android in terms of transparency, it us unfortunate because it doesnt provide the same look as Android and it becomes unusable. In pursuit curreny of thinking of a workaround. Any suggestions?
And you might include in the MauiMaps readme that this app will not run on windows. Map control does not appear available on Windows yet and will error out with a navigation error.
Hello Vladislav, good job, but when I add arround 1000 custom pins the adding process gets very slow and a lot of GC is happening.
I made my own logic now, but maybe there is a better solution.
The problem is ... if I add the, lets say, the tenth marker , your algorithm deletes all the 9 that already added and added it again.
This get's worse the more markers you add.
CustomPin once created loses base class functionality. When I assign Location to the pin after it was added to the map, it is not reflected on the map. Neither does changing pin Label text.
If pin is created with IsDraggable set to true, it can be dragged across the map. When I check the Location property after dragging to a new position, coordinates are same as passed in the Pin constructor.
Custom pins in your example represent cities. Cities don't move. If the pin represents something moving like a vehicle it would be an issue.
I did not test for Android.
Hi,
I'm looking at your code for the card stack layout and it is almost what I'm looking for ๐
Basically, I'm learning MAUI and I want to create an app with flash cards. So, I arrived at the point where I display the cards.
Now, the problems I'm facing are:
CardView
I tried to change the Content
but I get an error (Java.Lang.IllegalStateException: 'The specified child already has a parent. You must call removeView() on the child's parent first.'
, different in Windows)CardView
a TapGesture
, the SwipeGesture
or PanGesture
are not effected the view, although they are fired.var tapGesture = new TapGestureRecognizer();
tapGesture.Tapped += TapGesture_Tapped;
GestureRecognizers.Add(tapGesture);
Do you have any advice or code for that? Thank you in advance,
Enrico
Works fine on iOS but the sample code for android looks like this, how do I remove the container behind it?
Hey,
I'm trying out your sample https://github.com/VladislavAntonyuk/MauiSamples/blob/main/Auth/MauiAuth but no matter what I try, each time I attempt to login through the web redirect on Android I get the notification: unauthorized_client: The cllient does not exist or is not enabled for consumers.
I guess I need to tweak something in Azure on the app registration, but I do not know what. I think I have the correct redirect url's enabled.
Any tips?
When I drag the. json file into the window, the file cannot be loaded. Is it related to my computer system settings?
Is it possible to change the background of the bottom sheet to transparent so that we can style the sheet with maui controls... (eg - Corner radius with Border). Thanks :)
I wanted to put a close box on the bottomsheet view that would close the bottomsheet when tapped. It works fine on android but not iOS iOS it hides the bottomsheet but the UI becomes locked.
In my ModelView I have the following command.
[RelayCommand]
public async void HideBottomSheet()
{
#if ANDROID || IOS
Application.Current.MainPage.HideBottomSheet();
#endif
}
In Android PageExtensions I changed the code as follows...
A class variable d; set d to the bottomSheetdialog; and the hide it when the command is called.
public static partial class PageExtensions
{
static BottomSheetDialog d;
public static void ShowBottomSheet(this Page page, IView bottomSheetContent, bool dimDismiss)
{
var bottomSheetDialog = new BottomSheetDialog(Platform.CurrentActivity?.Window?.DecorView.FindViewById(Android.Resource.Id.Content)?.Context ?? throw new InvalidOperationException("Context is null"));
bottomSheetDialog.SetContentView(bottomSheetContent.ToPlatform(page.Handler?.MauiContext ?? throw new Exception("MauiContext is null")));
bottomSheetDialog.Behavior.Hideable = dimDismiss;
bottomSheetDialog.Behavior.FitToContents = true;
bottomSheetDialog.Show();
d = bottomSheetDialog;
}
public static void HideBottomSheet (this Page page)
{
d.Hide();
}
}
Did the same kind of thing on iOS but I suspect I have gotten the wrong variable and something is not working...
Any suggestions on how I can update the iOS one to work without hanging?
Thanks
public static partial class PageExtensions
{
public static void HideBottomSheet(this Page page)
{
c.PresentedView.Hidden = true;
}
static UISheetPresentationController c;
public static void ShowBottomSheet(this Page page, IView bottomSheetContent, bool dimDismiss)
{
var mauiContext = page.Handler?.MauiContext ?? throw new Exception("MauiContext is null");
var viewController = page.ToUIViewController(mauiContext);
var viewControllerToPresent = bottomSheetContent.ToUIViewController(mauiContext);
var sheet = viewControllerToPresent.SheetPresentationController;
if (sheet is not null)
{
sheet.Detents = new[]
{
UISheetPresentationControllerDetent.CreateMediumDetent(),
UISheetPresentationControllerDetent.CreateLargeDetent(),
};
sheet.LargestUndimmedDetentIdentifier = dimDismiss ? UISheetPresentationControllerDetentIdentifier.Unknown : UISheetPresentationControllerDetentIdentifier.Medium;
sheet.PrefersScrollingExpandsWhenScrolledToEdge = false;
sheet.PrefersEdgeAttachedInCompactHeight = true;
sheet.WidthFollowsPreferredContentSizeWhenEdgeAttached = true;
}
viewController.PresentViewController(viewControllerToPresent, animated: true, null);
c = sheet;
}
}
It is very nice and working well, but how can i localize the text from code pls ?
Dear Vladislav,
first of all: Thank you for your great examples and blog posts.
Second: I have an interesting problem with custom map pins only on iOS. When the Map view and viewmodel is loaded the first time, everything works fine, but after i change the itemsource for the pins (e.g. sort the collection - > Venues = new ObservableCollection(CachedVenues.OrderBy(x => x.Name));) the pins are gone, together with the own position marker on the map view. The fail is quiet (no exception whatsoever).
I tried to troubleshoot for 2 days now with no avail. I suspect the problem in the addAnnotation method together with the GetViewForAnnotations method within MapExtensions
Within the GetViewForAnnotations the condition
if (annotation is CustomAnnotation customAnnotation) {...}
triggers the first time round but not after the itemsource is changed, because then only MKPointAnnotation types are available.
To confirm: the code works as intended as long as the itemsource is not changed. As soon as the itemsource is sorted and the change notified all markers together with the own position marker are gone from the map.
I would be really greatful if you can give me a hint to point into the right direction if you got any idea.
Thanks and Stay Safe,
Rgds Vinc
<maps:Map x:Name="mapIOS" AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All" IsShowingUser="True" IsTrafficEnabled="True" ItemsSource="{Binding DataService.Venues, Mode=OneWay}"> <maps:Map.ItemTemplate> <DataTemplate> <pin:CustomPin x:DataType="models:Venue" Address="{Binding Address}" ImageSource="locationpin.png" InfoWindowClicked="Pin_InfoWindowClicked" Label="{Binding Name}" Map="{x:Reference mapIOS}" MarkerClicked="Pin_MarkerClicked"> <pin:CustomPin.Location> <MultiBinding Converter="{StaticResource LatLonToLocationConverter}"> <Binding Path="Latitude" /> <Binding Path="Longitude" /> </MultiBinding> </pin:CustomPin.Location> </pin:CustomPin> </DataTemplate> </maps:Map.ItemTemplate> </maps:Map>
Hello, after following your guide on how to customize Map pins, I noticed that my MarkerClicked
events are overwritten/missing. I can't seem to figure out how re-add them. The click events work when using the default map pin.
Tested on iOS 16.1.
I compiled the demo with Visual Studio 17.4 and .Net 7.0. (Tested on both Win and Mac )
Switch language not work under iOS.
But on windows and Android it's working fine.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.