Data Grid Control for .NET MAUI (Free plugin to Sort, Filter & Show Data)
October 04, 2023
Read MoreIn this video, we will see the recap of .NET MAUI articles post on 2023. Supercharge your .NET MAUI projects by referring this articles. ...
October 04, 2023
Read MoreIntroduction .NET MAUI, a cross-platform framework, empowers developers to build native mobile and desktop applications using C# and ...
.NET MAUI, a cross-platform framework, empowers developers to build native mobile and desktop applications using C# and XAML. It enables the creation of apps that seamlessly operate on Android, iOS, macOS, and Windows, all from a unified codebase. This open-source platform is an advancement of Xamarin Forms, expanding its reach to desktop scenarios while enhancing UI controls for improved performance and extensibility.
In this article, we will see how we can implement Localisation in .NET MAUI project.
As a first point, we need to implement the screen design as per our requirement. In this tutorial, we will use 3 controls - 2 labels, and button like in the following code block.
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:resource="clr-namespace:MauiLocalization"
x:Class="MauiLocalization.MainPage">
<ScrollView>
<VerticalStackLayout
Spacing="25"
Padding="30,0"
VerticalOptions="Center">
<Image
Source="dotnet_bot.png"
SemanticProperties.Description="Cute dot net bot waving hi to you!"
HeightRequest="200"
HorizontalOptions="Center" />
<Label
Text="{x:Static resource:LangResources.Helloworld}"
SemanticProperties.HeadingLevel="Level1"
FontSize="32"
HorizontalOptions="Center" />
<Label
Text="{x:Static resource:LangResources.WelcomeNote}"
SemanticProperties.HeadingLevel="Level2"
SemanticProperties.Description="Welcome to dot net Multi platform App U I"
FontSize="18"
HorizontalOptions="Center" />
<Button
x:Name="CounterBtn"
Text="Change to Tamil"
SemanticProperties.Hint="Counts the number of times you click"
Clicked="OnCounterClicked"
HorizontalOptions="Center" />
</VerticalStackLayout>
</ScrollView>
</ContentPage>
In this step, we will see the steps to create RESX file.
xmlns:resource="clr-namespace:MauiLocalization"
Text="{x:Static resource:LangResources.Helloworld}"
private void OnCounterClicked(object sender, EventArgs e)
{
if (CounterBtn.Text.Contains("Tamil"))
{
LangResources.Culture = new CultureInfo("ta");
CounterBtn.Text = "Change to English";
}
else
{
LangResources.Culture = CultureInfo.InvariantCulture;
CounterBtn.Text = "Change to Tamil";
}
App.Current.MainPage = new MainPage();
}
if (LangResources.Culture != null && LangResources.Culture.TwoLetterISOLanguageName.Contains("ta"))
{
CounterBtn.Text = "Change to English";
}
else
{
CounterBtn.Text = "Change to Tamil";
}
References
https://learn.microsoft.com/en-us/dotnet/core/extensions/resources
.NET MAUI is a powerful platform for building cross-platform mobile applications, and with the right tools and resources, it's eas...
A blog about android developement
.net multi-platform app ui
.NET MAUI is a powerful platform for building cross-platform mobile applications, and with the right tools and resources, it's easy to implement Avatar View to your app. In this tutorial, we'll walk you through the steps for adding Avatar View in .NET MAUI using .NET MAUI Community Toolkit.
.NET MAUI Community Toolkit is the key to achieve drawing in our App is to use Community.ToolKit.Maui NuGet package. It is a collection of reusable elements such as animations, behaviors converters, among others, for developing applications for iOS, Android, macOS and WinUI using MAUI.
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseMauiCommunityToolkit()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});
xmlns:toolkit="clr-namespace:CommunityToolkit.Maui.Views;assembly=CommunityToolkit.Maui"
<toolkit:AvatarView Text="AM"
FontSize="30"
TextColor="White"
BackgroundColor="Green"
BorderColor="White"
BorderWidth="5"
HeightRequest="150"
WidthRequest="150"
CornerRadius="120"
ImageSource="dotnet_bot.png"/>
.NET MAUI is a powerful platform for building cross-platform mobile applications, and with the right tools and resources, it's...
A blog about android developement
.net multi-platform app ui
.NET MAUI is a powerful platform for building cross-platform mobile applications, and with the right tools and resources, it's easy to add signature pad functionality to your app. In this tutorial, we'll walk you through the steps of signature pad in .NET MAUI using .NET MAUI Community Toolkit.
.NET MAUI Community Toolkit is the key to achieve drawing in our App is to use Community.ToolKit.Maui NuGet package. It is a collection of reusable elements such as animations, behaviors converters, among others, for developing applications for iOS, Android, macOS and WinUI using MAUI.
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseMauiCommunityToolkit()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});
xmlns:mct="clr-namespace:CommunityToolkit.Maui.Views;assembly=CommunityToolkit.Maui"
<mct:DrawingView x:Name="DrawBoard"
LineColor="Black"
LineWidth="5"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
HeightRequest="250"
IsMultiLineModeEnabled="True"
DrawingLineCompleted="DrawBoard_DrawingLineCompleted"
BackgroundColor="AliceBlue"/>
DrawBoard.Lines.Clear();
<Button Text="Clear Board"
Clicked="Button_Clicked"/>
void Button_Clicked(System.Object sender, System.EventArgs e)
{
DrawBoard.Lines.Clear();
}
<Image x:Name="ImageView"
WidthRequest="200"
HeightRequest="200"/>
private void DrawBoard_DrawingLineCompleted(System.Object sender, CommunityToolkit.Maui.Core.DrawingLineCompletedEventArgs e)
{
ImageView.Dispatcher.Dispatch(async() =>
{
var stream = await DrawBoard.GetImageStream(300, 300);
ImageView.Source = ImageSource.FromStream(() => stream);
});
}
Full Code:
.NET MAUI is a powerful platform for building cross-platform mobile applications, and with the right tools and resources, it'...
.NET MAUI is a powerful platform for building cross-platform mobile applications, and with the right tools and resources, it's easy to add barcode scanning functionality to your app. In this tutorial, we'll walk you through the steps of implementing a barcode scanner in .NET MAUI using the ZXing.Net.MAUI plugin.
The successor to ZXing.Net.Mobile: barcode scanning and generation for .NET MAUI applications. First, we need to add the ZXing.Net.MAUI library to our project as a dependency. To do this, open the NuGet Package Manager and search for "ZXing.Net.MAUI". Install the package in your .NET MAUI project.
Install
ZXing.Net.MAUI
NuGet package on your .NET MAUI application.
Make sure to initialize the plugin first in your
MauiProgram.cs
, see below
// Add the using to the top
using ZXing.Net.Maui;
// ... other code
public static MauiApp Create()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseBarcodeReader(); // Make sure to add this line
return builder.Build();
}
Now we just need to add the right permissions to our app metadata. Find below how to do that for each platform.
For Android go to your "AndroidManifest.xml" file (under the Platforms\Android folder) and add the following permissions inside of the "manifest" node.
<uses-permission android:name="android.permission.CAMERA" />
For iOS go to your "info.plist" file (under the Platforms\iOS folder) and add the following permissions inside of the "dict" node:
<key>NSCameraUsageDescription</key>
<string>This app uses barcode scanning to...</string>
Make sure that you enter a clear and valid reason for your app to access the camera. This description will be shown to the user.
Windows is not supported at this time for barcode scanning. You can however use the barcode generation. No extra permissions are required for that. For more information on permissions, see the Microsoft Docs.
If you're using the controls from XAML, make sure to add the right XML namespace in the root of your file, e.g:
xmlns:zxing="clr-namespace:ZXing.Net.Maui.Controls;assembly=ZXing.Net.MAUI"
<zxing:CameraBarcodeReaderView
x:Name="cameraBarcodeReaderView"
BarcodesDetected="BarcodesDetected" />
Full Code of MainPage.xaml:
cameraBarcodeReaderView.Options = new BarcodeReaderOptions
{
Formats = BarcodeFormats.OneDimensional,
AutoRotate = true,
Multiple = true
};
cameraBarcodeReaderView.IsTorchOn = !cameraBarcodeReaderView.IsTorchOn;
cameraBarcodeReaderView.CameraLocation
= cameraBarcodeReaderView.CameraLocation == CameraLocation.Rear ? CameraLocation.Front : CameraLocation.Rear;
protected void BarcodesDetected(object sender, BarcodeDetectionEventArgs e)
{
foreach (var barcode in e.Results)
Console.WriteLine($"Barcodes: {barcode.Format} -> {barcode.Value}");
}
Full code of MainPage.xaml.cs
In this tutorial, we will see how to use the local storage preferences in the .Net MAUI application. Preferences is stores data i...
In this tutorial, we will see how to use the local storage preferences in the
.Net MAUI application. Preferences is stores data in key-value pairs and can
be easily managed via the Preferences class from Microsoft.Maui.Storage
namespace.
Note:If we uninstall the app, will remove all local preferences.
Preferences are stored natively, which allows you to integrate your settings
into the native system settings.
In the below statement, will the get the value from existing preference or if preference value is not there automatic or return the default value.
For dropping preference key and value, clear and remove are used. For example, if you are switching to a different user or logging out, this will assist in clearing all preference key and value. We can use remove preference to get rid of a specific key preference in a mobile device.
In this tutorial, we will see how to display the local notification from the .Net MAUI application. For this, we are using the ...
In this tutorial, we will see how to display the local notification from the .Net MAUI application. For this, we are using the "Plugin.LocalNotification" plugin which is compatible with Xamarin.Forms and .Net MAUI. To know more, visit here.
In this tutorial, we will see how to capture screenshots on cross platforms using .Net MAUI. The name "Screenshots" indic...
In this tutorial, we will see how to capture screenshots on cross platforms using .Net MAUI. The name "Screenshots" indicates, the image that is the screen of our device allows us to capture the exact situation we want in the application when we use it.
In this tutorial series, we will see how to use animations in .NET Multi-platform App UI (.NET MAUI), this animation classes targ...
In this tutorial series, we will see how to use animations in .NET Multi-platform App UI (.NET MAUI), this animation classes target different properties of visual elements, with a typical introductory animation progressively changing a property from one value to another over a period of time.
© 2022, made with ❤ by Androidmads for developers
Follow Us
Were this world an endless plain, and by sailing eastward we could for ever reach new distances