Wednesday 22 February 2023

All About .NET MAUI

 What’s .NET MAUI?

.NET MAUI (.NET Multi-platform App UI) is a framework for building modern, multi-platform, natively compiled iOS, Android, macOS, Windows and apps using C# and XAML in a single codebase.

With .NET MAUI, you can build native applications from a single codebase for Android, iOS, macOS, Windows and Tizen which is backed by Samsung.

If you’ve used Xamarin Forms, MAUI will be very familiar to you. Instead of different projects for desktop, mobile, and each OS, all your code is in a single project. .NET MAUI also provides hosting Blazor in MAUI, with embedded web view controls to run Razor components natively on your target device. The decoupled UI and single project enables you to stay focused on one application instead of juggling the unique needs of multiple platforms. It’s the new baby of Microsoft and I know there will be more libraries and the broader ecosystem come alongside .NET MAUI in the following months.

Rich Components

UI component ecosystem is already rich.




You can get productive fast, with beautiful re-usable UI components from top component vendors like SyncfusionDevExpressUX DiversGrapeCityTelerik




Xamarin vs MAUI

.NET MAUI is the next step of Xamarin.Forms. I’ll show you some of the advantages that comes with MAUI.

1. Single project for different platforms

All platforms can be managed in a single project. This means, there will be no multiple projects for each target platform. As you know Xamarin uses separate projects for each platform. In MAUI, shared resource files are within the single project. A single application manifest that specifies the app title, id, and version. A single cross-platform app entry point helps you to develop faster.

2. Graphics APIs

Xamarin does not have direct APIs to handle any drawing requirements. You have to do it on the native side using renderers. But .NET MAUI abstracts native drawing. The cross-platform graphics functionality in .NET MAUI provides a drawing canvas for drawing and painting shapes.

Update: You can use Skiasharp in Xamarin.Forms to draw things.

3. .NET 6 support

.NET MAUI is integrated into .NET 6, on the other hand Xamarin.Forms is .NET Core 3.1 . Due to .NET 6 integration, you can use the new .NET 6 and C#10 features in .NET MAUI.

4. Slim renderers

In Xamarin App we were using Custom Renderers. There’s no custom renderers but now we can use Slim Renderers. Doing so makes your application lightweight and streamlines the development experience.

5. One location to manage all assets

You can manage resources like fonts, images, splash screen, CSS, or raw assets from one place. Where the Xamarin.Forms have multiple projects for those.

6. Multi-targeting to organize platform-specific code

A .NET MAUI project contains a Platforms folder, with each child folder representing a different supported platform. So you can easily manage different platform specific code.

7. Support for the Model View Update (MVU) pattern

As you know Xamarin.Forms supports Model-View-Viewmodel and ReactiveUI patterns. In addition to those, .NET MAUI supports Model-View-Update and Blazor development patterns. This pattern provides a unified way to build cross-platform native front ends from a single code base.

8. Support for Blazor

As we know, Blazor is one of the most adaptive programming models for building web applications. .NET 6 will extend Blazor’s target scenarios to include native desktop applications that may rely on web-based rendering. Blazor desktop will be structured similar to the way the Electron works.

9. Unification of libraries

.NET MAUI comes with the unification of critical libraries. It provides several benefits by merging the Xamarin.Essentials library into .NET MAUI so that you can easily use device capabilities like device sensors, photos, contacts and other services you use on a regular basis like authentication and secure storage.

10. Complete support for hot reloads

You can modify both your XAML and managed source code while the application is running. Then observe the result of your modifications without stopping, rebuilding and starting your application.

Why .NET MAUI?

Accessibility First

One major advantage of using native UI is the inherited accessibility support. It makes easy to create highly accessible applications with semantic services. Check out https://docs.microsoft.com/en-us/dotnet/maui/fundamentals/accessibility

• Properties such as description, hint, and heading level
• Focus
• Screen reader
• Automation properties

Easy to establish a new platform

.NET MAUI is architected for extensibility, so you never hit a wall. Take, for example, the Entry control — a canonical example of a control that renders differently on one platform. Android draws an underline below the text field, and developers often want to remove that underline. With .NET MAUI, customizing every Entry in your entire project is just a few lines of code.

APIs to access services

.NET MAUI is architected for extensibility, so you never hit a wall. Take, for example, the Entry control — a canonical example of a control that renders differently on one platform. Android draws an underline below the text field, and developers often want to remove that underline. With .NET MAUI, customizing every Entry in your entire project is just a few lines of code. Check out https://docs.microsoft.com/en-us/dotnet/maui

Global using statements and File scoped namespaces

.NET MAUI uses the new C# 10 features introduced in .NET 6, including global using statements and file scoped namespaces. This is great for reducing clutter in your files.



Single project for different platforms

In new .NET MAUI projects, platforms are placed in a subfolder that gives your focus to your application. Within your project’s Resources folder you have a single place to manage your fonts, images, app icon, splash screen, raw assets, and styling. .NET MAUI will do the work to optimize them for each platform’s unique requirements. See https://docs.microsoft.com/en-us/dotnet/maui/fundamentals/single-project.



Use Blazor for Desktop and Mobile

NET MAUI is also great for web developers looking to run web code in native client apps. You can use your web development skills to build cross-platform native client applications for mobile, desktop, and web. It executes your Blazor components natively on the device. No WebAssembly needed! And renders them to an embedded web view control. Your Blazor components compile and execute in the .NET process, they aren’t limited to the web platform and can leverage any native platform features, like notifications, Bluetooth, geo-location and sensors, filesystem and many more.

Optimized for Speed

There’s a good improvement on performance and reducing app size after .NET 6 transition. The team reduced the Java <-> C# call cycles. And no more creation C# objects from Java The .NET Podcast sample application is built with .NET MAUI.


  • First, it was starting up in 1299 ms
  • Now it’s 814 ms.
  • %37 percent improvement…


There’s the native application on the left side, and .NET MAUI on the right column. While the native application loads in half seconds, .NET MAUI adds 1 second overhead in JIT (Just in time) compilation. When AOT (ahead of time) compilation is enabled, it loads 2 times faster. In terms of the file size, when AOT (ahead of time) compilation is enabled, the file size getting larger but it loads very fast. So by doing AOT partially, the parts of your application that are only executed at startup, thus balancing over speed and size. See https://devblogs.microsoft.com/dotnet/announcing-net-maui-preview-9/#quick-android-startup

Migrating from a Xamarin App

The Manual Way

If you are thinking to migrate from a Xamarin application, you don’t need to rewrite your old Xamarin.Forms application to move them to .NET MAUI. You can use single-project features without merging all of your Xamarin.Forms projects into one project.

  • Convert the projects from .NET Framework to .NET SDK style.
  • Update namespaces.
  • Update any incompatible NuGet packages.
  • Address any breaking API changes.
  • Run the converted app and verify that it functions correctly.

See https://docs.microsoft.com/en-us/dotnet/maui/get-started/migrate

Upgrade Assistant


There is a tool developed by Microsoft. It’s called “Upgrade Assistant”. It’s not originally for .NET MAUI, but you can use it migrating your Xamarin.Forms projects. Further info, see https://dotnet.microsoft.com/en-us/platform/upgrade-assistant

dotnet tool install --global upgrade-assistant

Get Started .NET MAUI

To get started using .NET MAUI on Windows, install or update Visual Studio 2022 Preview to version 17.3 Preview 1.1. In the installer, choose the workload “.NET Multi-platform App UI development”.

For MAC install the new Visual Studio 2022 preview (17.3 Preview 1).



Learn .NET MAUI (for beginners)

Lastly, there’s a very practical 4 hours workshop from James Montemagno. He’s working in Microsoft since the Xamarin project. In this free YouTube course, you will learn the basics including how to build user interfaces , how MVVM and data binding works, how to navigate between pages, access platform features like geolocation, optimize data collections, and theme. This course has everything you need to learn the basics of .NET MAUI development. 


References

Here’s the list of resources I refer to and get help.

• https://devblogs.microsoft.com/dotnet/introducing-dotnet-maui-one-codebase-many-platforms/
• https://www.youtube.com/watch?v=s48vzy4sC0k
• https://www.banditoth.net/2021/12/30/upgrading-xamarin-forms-projects-to-net-maui/
• https://www.grapecity.com/blogs/whats-the-difference-between-maui-and-uno
• https://www.syncfusion.com/blogs/post/advantages-net-maui-over-xamarin.aspx
• https://dotnet.microsoft.com/en-us/apps/maui


.NET MAUI Local Push Notifications Sample

 



Nuget Package : https://github.com/thudugala/Plugin.LocalNotification

Sample Code: https://github.com/jfversluis/MauiLocalPushNotificationsSample

Tuesday 21 February 2023

10 Hints to Stay away from Normal Slip-ups in Xamarin.Forms Application Advancement

1. Using nested stackLayout

If we use nested stackLayouts in our application, it becomes very complicated to read or understand what’s going on. It will also deteriorate the app’s performance.

If we must use nested stackLayouts, we can use multiple children with a single parent stackLayout. Otherwise, it would be better to use a grid, which is more efficient than a stackLayout. By using a grid, we can easily read the written code and improve the app’s performance too.

The following code example demonstrates how to use the grid in Xamarin.Forms.

Instead of this:

<ContentPage ... xmlns:local="clr-namespace:Profile">

   <ContentPage.Content>

       <StackLayout>

<StackLayout orientation = "Horizontal">

       <Label Text=”Employee Name :”/>

                <Label Text=”John” />

</StackLayout>

    <StackLayout orientation = "Horizontal">

                <Label Text=”Designation :”/>

       <Label Text=”Manager” />

</StackLayout>

         <StackLayout orientation = "Horizontal">

                <Label Text=”Age :”/>

       <Label Text=”25” />

</StackLayout>

       </StackLayout>

   </ContentPage.Content>

</ContentPage>

Use this:

<ContentPage ... xmlns:local="clr-namespace:Profile">

   <ContentPage.Content>

       <Grid RowDefinitions=”Auto, Auto, Auto” ColumnDefinitions=”50*, 50*”>

         <Label Grid.Row=”0” Grid.Column=”0” Text=”Employee Name :”/>

         <Label Grid.Row="0" Grid.Column=”1” Text=”John”/>

         <Label Grid.Row=”1” Grid.Column=”0” Text=”Designation :”/>

         <Label Grid.Row="1" Grid.Column=”1” Text=”Manager”/>

         <Label Grid.Row=”2” Grid.Column=”0” Text=”Age :”/>

         <Label Grid.Row="2" Grid.Column=”1” Text=”25”/>

       </Grid>

    </ContentPage.Content>

  </ContentPage>


2. Ignoring MVVM pattern

MVVM (Model-view-viewmodel) pattern is used to separate domain logic and the presentation layer. By ignoring the MVVM pattern, we cannot reuse code. This makes it difficult to maintain and test the code, as some developers will implement it in the code-behind without using commands or data binding.

The main advantages of using MVVM are that it makes code easy to reuse, work out, maintain, and test. Once we implement code in the ViewModel, we can use the same ViewModel in multiple projects.

The following code example demonstrates how to use the MVVM pattern in Xamarin.Forms.

Instead of this:

<ContentPage ... xmlns:local="clr-namespace:login">  

    <ContentPage.BindingContext>  

        <local:LoginViewModel />  

    </ContentPage.BindingContext>  

    <Button Text = “Click Me!” Clicked =” LoginButton_Clicked” />

</ContentPage>


Public partial Class Login : ContentPage

{

    private async void LoginButton_Clicked(object sender, EventArgs e)      

    {

    }

}

Use this:

<ContentPage ... xmlns:local="clr-namespace:login">  

    <ContentPage.BindingContext>  

        <local:LoginViewModel />  

    </ContentPage.BindingContext>  

    <Button Text = “Click Me!” Command ={Binding ClickButtonCommand} />

</ContentPage>


Public Class LoginViewModel

{

    public ICommand ClickButtonCommand => new Command(Login);

    private void Login()

    {

    }

}

3.  Repeating the same templates in multiple views

When developing multiple views for an application, we should not use the same template code in every view. Doing so would complicate maintenance, consume more time, and cause rework. So, in these scenarios, we can use some common templates to avoid the repetition.

The following code example illustrates the procedure to avoid using the same template in every view. You can even create a CustomView and then include that in your MainPage.

<ContentView xmlns="http://xamarin.com/schemas/2014/forms"              xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"  x:Class="YourProject.CustomView">
 <label Text= “Common template” />
</ContentView>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:views="clr-namespace: MainPage;assembly= MainPage "
             x:Class="YourProject.YourPage">
    <views:CustomView/> 
</ContentPage>

4.  Using outdated libraries

When developing an application, make sure you are using the latest versions of your libraries and IDE in all platforms. If we use older versions in our application, there is a chance that it might not function in the newer versions of the platforms.

For example, in the case of iOS, you won’t be able to submit your app to the App Store if you haven’t used the latest version of Xcode to develop it.

Let’s say you are installing Xamarin.Essentials or other packages that use support libraries. You should ensure that all of your support libraries are up to date and are of the same version. Suppose we installed version 27.0.2 of the support libraries, and Xamarin.Essentials demands version 27.0.2.1, then we can’t deploy the application.

5.  Overusing platform-specific code

If we build applications with platform-specific code, we need to write the code for each platform. So, the implementation time will increase. So, try to switch to cross-platform code as much as possible.

6.  Repeating the same styles in multiple views

We should avoid using the same style code in every view while developing multiple views for an app. If we repeat the style code, the implementation time would increase. For any update in the style, we will have to manually make the change in every view in which we used the style. So, we can use common styles to avoid repetition.

The following code sample illustrates how to avoid repeating styles in every view. You can also create a CustomPage and include it in your MainPage.

Instead of this: (Same style in different views)

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:views="clr-namespace: MainPage;assembly= MainPage"
             x:Class="YourProject.MainPage">
<ContentPage.Resources>
        <!-- Implicit styles -->
        <Style x:Key=”lblstyle” TargetType=”Label">
            <Setter Property="BackgroundColor"  Value=”Red" />
        </Style>
    </ContentPage.Resources>
   <Label Text=”Test” style=”{StaticResource lblstyle}”> 
</ContentPage>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:views="clr-namespace: CustomPage;assembly= CustomPage"
             x:Class="YourProject.CustomPage">
<ContentPage.Resources>
        <!-- Implicit styles -->
        <Style x:Key=”lblstyle” TargetType=”Label">
            <Setter Property="BackgroundColor"  Value=”Red" />
        </Style>
    </ContentPage.Resources>
   <Label Text=”Test” style=”{StaticResource lblstyle}”> 
</ContentPage>

Use this: (Common Styles)

<ResourceDictionary
    x:Class="YourProject.Styles"
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    mc:Ignorable="d">
<Style x:Key=”lblstyle” TargetType=”Label">
         <Setter Property="BackgroundColor"  Value=”Red" />
  </Style>
</ ResourceDictionary>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:views="clr-namespace: MainPage;assembly= MainPage"
             x:Class="YourProject.MainPage">
<ContentPage.Resources>
       <styles/>
</ContentPage.Resources>
  <Label Text=”Test” style=”{StaticResource lblstyle}”> 
</ContentPage>

7.  Not covering all OS versions

If we don’t maintain the latest OS version, we can’t develop applications for the latest devices. So, you should always use the latest Android SDK tools and Android API references when developing your applications. You can update to the latest versions using the Android SDK Manager. Also, the target SDK version of your Android projects must be set to the latest installed platforms. For iOS, we must set the target version to iOS 9 or higher.

8.  Blocking the main thread

If we block the main thread, our app won’t work smoothly and its performance will suffer. So, to avoid using the main thread to perform heavy operations, we can either use async/await or background workers to do them. We should use the main thread only to update the UI.

9.  Not maintaining the same NuGet version in all platforms

When you downgrade or upgrade NuGet packages, make sure to maintain the same version in all platforms. Otherwise, you may not be able to build and deploy the project to the target devices successfully.

10.  No unit testing

If we don’t use unit test cases in our application, it is very hard to find errors and maintain the implemented code.

Follow these tips to write unit tests in your application:

  • The unit test should be independent.
  • Code coverage of testing code should be above 85%.
  • The unit test should be simple and there shouldn’t be any confusion in the code.
  • Execution of the unit test should be fast and should generate accurate results.
  • The unit test should cover one condition of a method at a time.
  • There should be a separate project for writing unit tests.
  • The parent class should be tested first, and then the child class.
  • The unit test project should be maintained and well organized.

Thanks for reading.

Tuesday 14 February 2023


BBC Xamarin News - Api


Client for http://newsapi.org in Xamarin Forms.

  1. Create an application for displaying the news from the.
  2. BBC feed: https://newsapi.org/bbc-news-api
  3. To use this feed, you'll need to generate an API key.
  4. The application should display a list of the current news with the ability to refresh.
  5. Each news item should have title, description, published date and associated image.
  6. Selecting a news item should open a link to that story within the app.
  7. The only requirement is to use the Xamarin platform, everything else is up to the candidate.








This Source code  is just for reference purpose only,You need to update the new model and URL if required.

Ex : GET method : 



Source Code :  LINK




 

How to Use Chat GPT: Step by Step Guide to Start Open AI ChatGPT


Visit GPT is a computer based intelligence language model that is surprising the world. Know how to utilize Talk GPT, bit by bit interaction to utilize visit GPT, chatGPT login, what is chatGPT, talk GPT site, complete manual for use talk GPT, its full structure.

Visit GPT is a progressive computer based intelligence language model that is overwhelming the world. Visit GPT full structure is Talk Generative Pre-Prepared Transformer. It is accepted that Google's minstrel will be its greatest rival. Know how to utilize Visit GPT, bit by bit cycle to utilize talk GPT, a total manual for use talk GPT, chatGPT information exchange, its full structure.

What is ChatGPT?

In straightforward language, ChatGPT is a computer based intelligence fueled chatbot that has been created by San Francisco based startup OpenAI and is accessible for public use on internet browsers. It very well may be utilized on its site which is chat.openai.com. ChatGPT is fueled by LLM which is huge language model. This implies that chatGPT is fit for grasping human-like reactions.

It has set off another worldwide race in the man-made intelligence world inside each brief length of time. It was delivered in November 2022 and has been the discussion of the business world from that point forward. However, what makes ChatGPT special? All things considered, ChatGPT is equipped for having discussions with you like you are conversing with a truly learned individual. Visit GPT can have discussions with you on history, reasoning, culture, and so forth. Other than this, it can likewise create verses of your #1 vocalist, assist you with composing code, and so forth.

Talk GPT Login

In the event that you are pondering the technique for Visit GPT login, here is the step by guide for you. Visit GPT site is chat.openai.com. One necessities to join on this site to have the option to utilize this moving application. OpenAI Visit GPT has been planned so that an individual of all ages can utilize it. OpenAI creators have not sent off the application rendition of it yet. Thus, you would need to join on OpenAI site to utilize it.

Instructions to utilize Talk GPT - Bit by bit Methodology

The new simulated intelligence chatbot which is Talk GPT has surprised the world with its momentous use. In the event that you are enthused about evaluating Talk GPT and need to know how to utilize Visit GPT, then here is a finished aide for you. This article is a finished bit by bit manual for utilizing the simulated intelligence device.

Talk GPT is a recently sent off computer based intelligence chatbot that was sent off in November 2022. It represents Talk Generative Pre-Prepared Transformer. Talk GPT has been standing out as truly newsworthy since the day it was sent off because of the errands that it is fit for performing. It offers you responses to each question of yours, for example, it will assist you with arranging a party, give you complete direction in your school/school tasks, compose code, and so on. As a matter of fact, what is frightening is the way that it has shown its power by marvellous the law legal defense test and furthermore handling Google's coding test. Need to investigate talk GPT more? You should go through this article and ability to utilize it.

How to utilize Visit GPT?

Talk GPT is basic and simple to utilize. One thing that you ought to remember while involving it is that you input explanation inquiries in it. To utilize visit GPT, the principal thing that you want to do is to make a record on OpenAI. Given underneath is the bit by bit manual for involving talk GPT in a problem free way.

Join on OpenAI
The initial step to utilize visit CGP is to join on OpenAI and make a record on it. Visit https://chat.openai.com/auth/login.




Make a record on ChatGPT
The accompanying page will show up on your screen once you visit the OpenAI site. Click on the information exchange choice. The accompanying page will show up on your screen. Click on the sign-up choice. In the event that the site is requiring some investment to stack, then revive the page or return after some time.

Confirm your Record
After you have effectively pursued ChatGPT, the following stage is to confirm your record. On the off chance that you joined through your email id, a confirmation email will be shipped off your inbox. Follow the connection shipped off your cell phone and complete the confirmation interaction. Top off the subtleties asked and continue.

How to utilize Talk GPT after Record Creation?
Since you have effectively made a record on Talk GPT, you can start to utilize it. It is straightforward and simple to utilize. Just sort any inquiry that you wish to realize about in the hunt bar.

For instance, if you need to be familiar with the recipe of a dish, then, at that point, just sort your question in the hunt box.

Here is the screen capture of the Talk GPT search bar.






Visit GPT's Greatest Rival

On the off chance that we take a gander at the greatest contender of Talk GPT, we could accept that Google's Versifier will be the one to supplant it. Google at long last revealed its artificial intelligence Chatbot which is "Poet" on February 6 which will give direct rivalry to Talk GPT. Like Visit GPT, Poet also is fit for having human-like discussions, do interpretations and give exact data to the client. It is fueled by Google's language model which is LaMDA (Language Model for Discourse Applications).

Google will join outside criticism with inward testing to guarantee Minstrel's reactions meet "a high bar for quality, security and groundedness in true data." However there are numerous different choices to visit GPT, notwithstanding, in the event that realities are to be accepted, Google's artificial intelligence chatbot "Poet" has the ability to contend with it.

When will poet be sent off?

The hunt goliath Google declared that it will be "freeing it up to confided in analyzers in front of making it all the more broadly accessible to general society before long." It will be very fascinating to perceive how Google will foster its chatbot to go up against visit GPT and how individuals would track down it to utilize.

Could I at any point utilize visit GPT on versatile?

Tragically, Talk GPT is inaccessible on cell phones as of now. Along these lines, it can't be found in Google Play Store for Android and Apple Application store for iPhone. Visit GPT s actually going through improvement. Along these lines, it tends to be just utilized on chat.openai.com.




ChatGPT Application

The world is interested about utilizing the ChatGPT application. In any case, you ought to know that this simulated intelligence isn't yet made accessible to be downloaded as an application adaptation.

You can utilize ChatGPT on your cell phone program for nothing by visiting any internet browser, for example, Google Chrome, Firefox, and so on. Then at the lower part of the portable screen, click on the "Attempt ChatGPT" flag. Login/Information exchange utilizing your certifications and go ahead and utilize this computer based intelligence bot to get your inquiries responded to.

Is Visit GPT allowed to utilize?

Indeed, Visit GPT is allowed to utilize. According to certain assessments, OpenAI spends around $3 million every month to proceed with its utilization for individuals. Be that as it may, OpenAI has likewise presented its exceptional form which will be chargeable in the approaching future.

All About .NET MAUI

  What’s .NET MAUI? .NET MAUI (.NET Multi-platform App UI) is a framework for building modern, multi-platform, natively compiled iOS, Androi...

Ads2