Posts

Showing posts with the label xamarinforms

[XAMARIN FORMS] Background task for 'closed' applications

Image
Background task for 'closed' applications Handling a background task in Xamarin Forms, even when the application is closed, can be challenging due to the mobile operating systems' restrictions on background activities. Here's a detailed solution using a combination of Dependency Service , Background Services , and Platform-Specific Implementations . Step 1: Create an Interface First, create an interface in your shared Xamarin Forms project that defines the method for starting the background task. public interface IBackgroundTask { void StartBackgroundTask(); } Step 2: Implement Platform-Specific Services Android Implementation: In your Android project, create a service that implements the IBackgroundTask interface. Create a Service: [Service] public class MyBackgroundService : Service { public override IBinder OnBind(Intent intent) => null; public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId...

[Xamarin Forms] Entry with rounded borders in your app

Image
Entry with rounded borders in your app (Xamarin Forms, NET MAUI) I know for some people it will be obvious, but I always seepeople asking how to make a custom Entry control with rounded borders...  To add rounded corners globally to Entry controls in a Xamarin Forms or .NET MAUI application, you can define a Style in the App.xaml (or Styles.xaml for .NET MAUI). This style will automatically apply to all Entry controls in your app, saving you from having to manually style each one. Example Define the global style in App.xaml : <Application.Resources> <ResourceDictionary> <Style TargetType="Entry"> <Setter Property="BackgroundColor" Value="White"/> <Setter Property="TextColor" Value="Black"/> <Setter Property="CornerRadius" Value="10"/> <Setter Property="HeightRequest" Value="50"/> ...

[Xamarin Forms]Page navigation summary

Image
[Xamarin Forms] Page navigation summary 1- The different navigation possibilities In this article will we list and sum up how we can navigate inside a Xamarin Forms application.  In Xamarin.Forms, you can navigate between pages using several methods, we will enumerate it and give a brief description / use case for each : Push/Pop Navigation : Using Navigation.PushAsync() and Navigation.PopAsync() for stack-based navigation. Modal Navigation : Using Navigation.PushModalAsync() and Navigation.PopModalAsync() for displaying pages modally. Master-Detail Navigation : Using MasterDetailPage to manage a master menu and a detail page. Tabbed Navigation : Using TabbedPage for navigation between different tabs. Carousel Navigation : Using CarouselPage to swipe through pages in a carousel-style interface. Shell Navigation : Using Xamarin.Forms Shell for a unified navigation paradigm with URL-based routing and flyout menus. Custom Navigation : Or if you want to customize and design a g...