Delpin Susai Raj Monday, 7 December 2020

Xamarin.Forms - Open App Store or Play Store in XamarinApp

 In this blog post, you will learn how to Open Play Store or App Store in XamarinApp.

Introduction

Xamarin.Forms code runs on multiple platforms - each of which has its own filesystem. This means that reading and writing files is most easily done using the native file APIs on each platform. Alternatively, embedded resources are a simpler solution to distribute data files with an app.

Prerequisites

  • Visual Studio 2017 or later (Windows or Mac)

Setting up a Xamarin.Forms Project

Start by creating a new Xamarin.Forms project. You wíll learn more by going through the steps yourself.

Create a new or existing Xamarin forms(.Net standard) Project. With Android and iOS Platform. 

Note: Your app must be live in App store and Playstore 

Android

Here, you need the Android app id Ex:com.twitter.android.

I'm using twitter for this sample.

https://play.google.com/store/apps/details?id=com.twitter.android

Code

iOS

Here, you need AppName and AppId with location you will get appname and aped from apple developer connect.

https://apps.apple.com/in/app/twitter/id333903271

Code

Simple UI

MainPage.xaml

Full Source Code

MainPage.xaml.cs

Alternate way

You can use Lancher.OpenAsync also for opening App Store and Play store.

Using Dependency Service

Interface

iOS Implementation

Below sample code for open App store in App iOS.

Android Implementation

Below sample code for open play store in App android. 

Debug your App

I hope you have understood you will learn how to Open Play Store or App Store in XamarinApp.

Thanks for reading. Please share your comments and feedback. Happy Coding :)

Delpin Susai Raj Friday, 20 November 2020

Xamarin.Forms - File Browser

 In this blog post, you will learn how to pick files from your device, Drive, iCloud in Xamarin.Forms.

Introduction

Xamarin.Forms code runs on multiple platforms - each of which has its own filesystem. This means that reading and writing files is most easily done using the native file APIs on each platform. Alternatively, embedded resources are a simpler solution to distribute data files with an app.

Prerequisites

  • Visual Studio 2017 or later (Windows or Mac)

Setting up a Xamarin.Forms Project

 Start by creating a new Xamarin.Forms project. You wíll learn more by going through the steps yourself.

 Create a new or existing Xamarin forms(.Net standard) Project. With Android and iOS Platform. 

Nuget

Install following Nuget from Nuget Manager In your visual studio.

Name.      : Xamarin.Plugin.FilePicker

Version    : 2.1.41

Url           : https://www.nuget.org/packages/Xamarin.Plugin.FilePicker/

Xamarin.Essentials

Xamarin.Essentials also supports File Picker but it's in Preview. Once the FilePicker moved to stable you can update Xamarin.Pulgin.FilePicker to Xamarin.Essentials

https://docs.microsoft.com/en-us/xamarin/essentials/file-picker

Setup UI

Now, I created simple UI for file browser.

MainPage.xaml

File Browser

Below code for file picker, Here will get two values FileName and FilePath.

File Types

Note, you can define the file types for platform specific.

Reference for other file types.

https://stackoverflow.com/questions/41797644/xamarin-ios-filtering-out-the-filetype-show-on-document-picker

MainPage.Xaml.cs

Debug your App



Once select the file you will get the FileName and FilePath.

I hope you have understood you will learn how to browse file in your device and drive in Xamarin.Forms..

Thanks for reading. Please share your comments and feedback. Happy Coding :)

Delpin Susai Raj Thursday, 12 November 2020

Xamarin.Forms - Custom TitleView

 In this blog post, you will learn how to create a custom TitleView in Xamarin.Forms.

Introduction

Xamarin.Forms code runs on multiple platforms - each of which has its own filesystem. This means that reading and writing files is most easily done using the native file APIs on each platform. Alternatively, embedded resources are a simpler solution to distribute data files with an app.

Prerequisites

  • Visual Studio 2017 or later (Windows or Mac)

Setting up a Xamarin.Forms Project

Start by creating a new Xamarin.Forms project. You wíll learn more by going through the steps yourself. Create a new or existing Xamarin forms(.Net standard) Project. With Android and iOS Platform. 

Simple Title

Simple TitleView with NavigationPage

App.Xaml.cs

Your page must be a Navigation Page

Here, we going to use NavigationPage,TitleView. You can use this for Custom TitleView.

MainPage.Xaml

Title with Icon

Now, added Title with Image in TitleView


TitleView with SearchView

You can add SearchBar also in the TitleView

Custom TitleView

Here, Going to create a common TitleView, you can reuse your Content pages.

TitleView.Xaml

Consume TitleView

Now, Consume the TitleView from your custom files folder.

I hope you have understood you will learn how to create a custom TitleView in Xamarin.Forms.

Thanks for reading. Please share your comments and feedback. 

Happy Coding :)

Delpin Susai Raj Friday, 23 October 2020

Xamarin.Forms - Mobile Network Speed Check(Slow or Fast) in Android

In this blog post, you will learn how to check you mobile network speed(slow or speed) using android native in Xamarin.Forms.



Introduction

Xamarin.Forms code runs on multiple platforms - each of which has its own filesystem. This means that reading and writing files is most easily done using the native file APIs on each platform. Alternatively, embedded resources are a simpler solution to distribute data files with an app.

Prerequisites

  • Visual Studio 2017 or later (Windows or Mac)

Setting up a Xamarin.Forms Project

 Start by creating a new Xamarin.Forms project. You wíll learn more by going through the steps yourself.

Create a new or existing Xamarin forms(.Net standard) Project. With Android and iOS Platform. 


Create a Interface

Create a NetworkConnectivity

Following code will check the Mobile network connection and Check the Network status whether speed or slow.

NetworkConnectivity.cs

Android Implementation

Here, Implement the Interface and return the network status.

NetworkHelper.cs


Consume the Network helper

Here, you will call the Network helper class and you will get the network speed.

MainPage.Xaml


Here I shows the result in toast. 

MainPage.xaml.cs


Run



I hope you have understood you will learn how to check you mobile network speed(slow or speed) using android native in Xamarin.Forms.

Thanks for reading. Please share your comments and feedback. 

Happy Coding :)

Delpin Susai Raj Wednesday, 21 October 2020

Xamarin.Forms - Network Speed Monitor

 In this blog post, you will learn how to monitor you network speed in Xamarin.Forms.

Introduction

Xamarin.Forms code runs on multiple platforms - each of which has its own filesystem. This means that reading and writing files is most easily done using the native file APIs on each platform. Alternatively, embedded resources are a simpler solution to distribute data files with an app.

Prerequisites

  • Visual Studio 2017 or later (Windows or Mac)

Setting up a Xamarin.Forms Project

Start by creating a new Xamarin.Forms project. You wíll learn more by going through the steps yourself.

Create a new or existing Xamarin forms(.Net standard) Project. With Android and iOS Platform.


 Network Monitor 

Now, create a network helper class for check network connectivity in xamarin.froms.

NetworkHelper.cs


Consuming Network helper

Here, you will call the Network helper class and you will get the network speed.

MainPage.Xaml


Here I shows the result in toast. 

MainPage.xaml.cs


Run



I hope you have understood you will learn how to check network speed in Xamarin.Forms.

Thanks for reading. Please share your comments and feedback. 

Happy Coding :)

Delpin Susai Raj Monday, 12 October 2020

Enable Dark Mode in iOS Simulator

 

Make sure your iOS version should be iOS 13 or Later

Goto Settings in your iOS Simulator.

Now scroll down in settings, you're able to see the Developer in the list. Click Developer.

Now, Enable the Dark Appearance toggle. Your simulator will behave dark mode.

Your simulator is Dark Mode.

I hope you have understood how to enable the dark mode in iOS Simulator.

Thanks for reading. Please share your comments and feedback. Happy Coding :)

Xamarin.Forms - Support Dark Mode

In this blog post, you will learn how to give support Dark Mode in Xamarin.Forms.

Introduction

Xamarin.Forms code runs on multiple platforms - each of which has its own filesystem. This means that reading and writing files is most easily done using the native file APIs on each platform. Alternatively, embedded resources are a simpler solution to distribute data files with an app.

Dark Mode


Nowadays iOS and Android apps should support both Dark and Light Theme.

Prerequisites

  • Visual Studio 2017 or later (Windows or Mac)

Setting up a Xamarin.Forms Project

 Start by creating a new Xamarin.Forms project. You wíll learn more by going through the steps yourself.

Create a new or existing Xamarin forms(.Net standard) Project. With Android and iOS Platform. 

Create a Theme

Create a ResourceDictionary for both Light and Dark Theme.

DarkTheme.xaml

LightTheme.xaml


Set App Theme

In app.xaml you can set the default theme.

App.xaml

Now, Create a Enum in App.xaml.cs

Create a Interface

Create a interface for set Theme at runtime.


iOS Implementation

Below code to change the Theme at runtime.

ThemeHelper.cs



Android Implementation

Below code to change the Theme at runtime.

ThemeHelper.cs



Consuming the Styles


Now, you can use the resource "DynamicResource BackgroundColor" like this.




Click the "Play" button to try it out.

Dark Mode


Light Mode

I hope you have understood you will learn how to give support Dark Mode in Xamarin.Forms..

Thanks for reading. Please share your comments and feedback. 

Happy Coding :)

Delpin Susai Raj Wednesday, 15 July 2020

Xamarin.Forms - Debugging WebView

In this blog post, you will learn how to debugging WebView in xamarin forms.

Introduction
 
Xamarin.Forms code runs on multiple platforms, each of which has its own filesystem. This means that reading and writing files are most easily done using the native file APIs on each platform. Alternatively, embedded resources are a simpler solution to distribute data files with an app.

Debugging Webview

Mobile developers are facing major difficulties for debugging web URLs. I  going to explain how to debug your xamarin.forms webview in an Emulator or simulator.

Prerequisites
  • Visual Studio 2017 or later (Windows or Mac)
Setting up a Xamarin.Forms Project
 
Start by creating a new Xamarin.Forms project. You will learn more by going through the steps yourself.
 
Create a new or existing Xamarin forms (.Net standard) Project with Android and iOS Platform.

Choose the Mobile App (Xamarin. forms) project under C# and Mobile.
 
Name your app. You probably want your project and solution to use the same name as your app. Put it on your preferred location for projects and click "Create".
 
Now, select the blank app and target platforms - Android, iOS and Windows (UWP).
 
Subsequently, go to the solution. In there, you get all the files and sources of your project (.NET Standard). Now, select the XAML page and double-click to open the MainPage.Xaml page.
 
You now have a basic Xamarin.Forms app. Click the Play button to try it out.

Create a Custom Webview

Here going to create a custom webview inherit from webview for debug webview.

CustomWebView.cs


Android Implementation

Here, Create a custom renderer for enable debugging in android.

CustomWebViewRenderer.cs


iOS Implementation
 
Here, Create a custom renderer for enabling the Debugging in Webview.
 
CustomWebViewRenderer.cs


Consuming the CustomWebview
 
Here, consume the Custom Webview in your xaml

Add Namespace


Add your Custom Webview

MyWebPage.xaml


MyWebPage.xaml.cs


Android

Note: Must add the following line in your webview renderer


Go to Chrome on your Machine then inspect any webpage. Then click three dots, then go to More tools > Remote Devices. Now you can see at the bottom device setting URL you can click that URL.

chrome://inspect/#devices

Run your app in Emulator

Now go to the webpage you able to see your webpage link then click inspect.

Finally, you can inspect your webview.

iOS

Note: Check your iOS simulator have web inspector option enable it.
Go to Settings > Safari > Advanced, and toggling the Web Inspector option on.

Next, you must also enable developer tools in Safari. Go to Safari > Preferences in the menu bar. Click on the Advanced tab and then enable the Show Develop menu option at the bottom.

Finally, Run your app the go-to Safari, Click on Develop in the menu bar and hover over the dropdown option that is your iOS device's name to show a list of webview instances running on your iOS device

 
I hope you have understood how to enable debugging in webview in Xamarin.Forms.
 
Thanks for reading. Please share your comments and feedback. Happy Coding :)
Delpin Susai Raj Friday, 19 June 2020

Xamarin.Forms - Enable Default Zooming in Webview

In this blog post, you will learn how to enable webview default zooming in xamarin forms.

Introduction
 
Xamarin.Forms code runs on multiple platforms, each of which has its own filesystem. This means that reading and writing files are most easily done using the native file APIs on each platform. Alternatively, embedded resources are a simpler solution to distribute data files with an app.

Prerequisites
  • Visual Studio 2017 or later (Windows or Mac)
Setting up a Xamarin.Forms Project
 
Start by creating a new Xamarin.Forms project. You will learn more by going through the steps yourself.
 
Create a new or existing Xamarin forms (.Net standard) Project with Android and iOS Platform.

Choose the Mobile App (Xamarin. forms) project under C# and Mobile.
 
Name your app. You probably want your project and solution to use the same name as your app. Put it on your preferred location for projects and click "Create".
 
Now, select the blank app and target platforms - Android, iOS, and Windows (UWP).
 
Subsequently, go to the solution. In there, you get all the files and sources of your project (.NET Standard). Now, select the XAML page and double-click to open the MainPage.Xaml page.
 
You now have a basic Xamarin.Forms app. Click the Play button to try it out.

Create a Custom Webview

Here going to create a custom webview inherit from webview for custom rendering to enable zooming.

CustomWebView.cs


Android Implementation
 
There are two ways in android.

1. Use Platform Specific code.

Following code snippets enable the default zooming in webview.

MyWebView.xaml.cs


2. Custom Renderer

Here, Create a custom renderer for enabling zooming in android.

CustomWebViewRenderer.cs


iOS Implementation
 
Here, Create a custom renderer for enabling the webview default zooming in iOS.
 
CustomWebViewRenderer.cs


Consuming the CustomWebview
 
Here, consume the Custom Webview in your xaml

Add Namespace


Add your Custom Webview

MyWebPage.xaml


MyWebPage.xaml.cs


Click the "Play" button to try it out

Android 
You can test zoom by emulator also use Shift + ctrl + Left click and mouse move

iOS 
Simulator also support zoom use Alt + Left click and mouse move

Wow, It's working.😍
 
I hope you have understood how to enable webview default zooming in Xamarin.Forms.
 
Thanks for reading. Please share your comments and feedback.

Happy Coding 🙌
Delpin Susai Raj Monday, 15 June 2020

Xamarin.Forms - Working with PDFView and Pinch Zoom

In this blog post, you will learn how to implement PDF view with pinch-zoom in xamarin forms.

Introduction
 
Xamarin.Forms code runs on multiple platforms, each of which has its own filesystem. This means that reading and writing files are most easily done using the native file APIs on each platform. Alternatively, embedded resources are a simpler solution to distribute data files with an app.

PDF Viewer


The Problem(Android)

PDFView doesn't support the default webview in android xamarin forms.

Solution

PDFView is the biggest issue in android webview. I solved this problem by using google drive viewer and google doc viewer.
there is another way to view pdf files using pdfjs. but pdfjs doesn't support pinch zoom.


Note: The pdf URL must be extension.PDF and public.

Prerequisites
  • Visual Studio 2017 or later (Windows or Mac)
Setting up a Xamarin.Forms Project
 
Start by creating a new Xamarin.Forms project. You will learn more by going through the steps yourself.
 
Create a new or existing Xamarin forms (.Net standard) Project with Android and iOS Platform.

Choose the Mobile App (Xamarin. forms) project under C# and Mobile.
 
Name your app. You probably want your project and solution to use the same name as your app. Put it on your preferred location for projects and click "Create".
 
Now, select the blank app and target platforms - Android, iOS, and Windows (UWP).
 
Subsequently, go to the solution. In there, you get all the files and sources of your project (.NET Standard). Now, select the XAML page and double-click to open the MainPage.Xaml page.
 
You now have a basic Xamarin.Forms app. Click the Play button to try it out.

Create a Custom Webview

Here going to create a custom webview inherit from webview for custom rendering. I'm going to create two bindable properties following.
  1. Uri
  2. IsPDF
PDFView.cs

Android Implementation
 
Here, Create a custom renderer for webview. for android the webview doesn't support pdf file preview. so I'm going to view pdf files Google drive viewer.
Note: The Url must be an extension .PDF and public. 


Another Solution


PDFViewRenderer.cs


iOS Implementation
 
Here, Create a custom renderer for webview to load pdf files in webview.
 
PDFViewRenderer.cs


Consuming the CustomWebview
 
Here, consume the Custom Webview in your xaml

Add Namespace


Add your Custom Webview

PDFView.xaml


PDFView.xaml.cs


Click the "Play" button to try it out

Android 
You can test Pinch zoom by emulator also use Shift + ctrl + Left click and mouse move

iOS 
Simulator also supports pinch-zoom use Alt + Left click and mouse move

Wow, It's working.
I hope you have understood how to implement PDF view with pinch-zoom in Xamarin.Forms.
 
Thanks for reading. Please share your comments and feedback. Happy Coding :)
Delpin Susai Raj Monday, 3 February 2020

Xamarin.Forms - Use BindableProperty in Effects

In this blog, you will learn how to use BindableProperty Effects in Xamarin.Forms


Tint Color Sample -  https://xamarinmonkeys.blogspot.com/2020/02/xamarinforms-tint-image-using-effects.html

(The Blog about change Image color at Runtime using Tint Color)


Introduction

Xamarin.Forms code runs on multiple platforms - each of which has its own filesystem. This means that reading and writing files are most easily done using the native file APIs on each platform. Alternatively, embedded resources are a simpler solution to distribute data files with an app.

Tint Image

TintImage is used for change image color at runtime with the help of effects, you can achieve with custom render also. Tint images mainly used to reduce the usage of the images.

BindableProperty

Attached properties can be used to define effect parameters that respond to runtime property changes. This article demonstrates using attached properties to pass parameters to an effect and changing a parameter at runtime.

Prerequisites
  • Visual Studio 2017 or later (Windows or Mac)
The Problem

We are not able to create a BindableProperty in Effect.

Solution

Create Effect

Now, Create a TintImage class inherit from RoutingEffect for Change image color.

TintImage.cs

Create Static Class

Here, I'm Going to create a Static Class for creating BindableProperty to my Effect.

TintImageEffect.cs

Android Implementation

Here, Implement Platform Effects for TintImage at Runtime.

TintImageImpl.cs

iOS Implementation

Here, Implement Platform Effects for TintImage at Runtime.

TintImageImpl.cs

Create ViewModel

Now, Create a Property for Binding the TintColor to View. and Create ChangeColorCommand For Change image color at runtime.

MainPageViewModel.cs

Consuming the TintImage

Now, Use the TintImage Effect in your XAML code.

MainPage.xaml

Click the "Play" button to try it out.

Wow, It's Working.😍

I hope you have understood how to use BindableProperty Effects in Xamarin.Forms.

Thanks for reading. Please share your comments and feedback. Happy Coding 🙌
Delpin Susai Raj Sunday, 2 February 2020

Xamarin.Forms - Tint Image Color Using Effects

In this blog post, you will learn how to Change image color using Tint Color Effects in Xamarin.Forms.

Introduction

Xamarin.Forms code runs on multiple platforms - each of which has its own filesystem. This means that reading and writing files are most easily done using the native file APIs on each platform. Alternatively, embedded resources are a simpler solution to distribute data files with an app.

Tint Color

TintImage is used for change image color at runtime with the help of effects, you can achieve with custom render also. Tint images mainly used for reducing the usage of the images.

Prerequisites
  • Visual Studio 2017 or later (Windows or Mac)
Create TintImage

The Actual Image Color is Blue 

Now, Create a TintImage class inherit from RoutingEffect for Change image color.

TintImage.cs

Android Implementation

Here, Implement Platform Effects for TintImage at Runtime.

TintImageImpl.cs

iOS Implementation

Here, Implement Platform Effects for TintImage at Runtime.

TintImageImpl.cs

Consuming the TintImage

Now, Use the TintImage Effect in your XAML code.

MainPage.xaml

Click the "Play" button to try it out.

Wow, It's Working.😍

I hope you have understood how to Change image color using Tint Color Effects in Xamarin.Forms.

Thanks for reading. Please share your comments and feedback. Happy Coding 😀🙌
Delpin Susai Raj Monday, 27 January 2020

Xamarin.Forms - Bottom TabbedPage in Android

In this blog post, you will learn how to Change Tabbed Page Top to Bottom for Android Device in Xamarin.Forms.

Introduction

Xamarin.Forms code runs on multiple platforms - each of which has its own filesystem. This means that reading and writing files is most easily done using the native file APIs on each platform. Alternatively, embedded resources are a simpler solution to distribute data files with an app.


Prerequisites
  • Visual Studio 2017 or later (Windows or Mac)
  • Xamarin.Forms 3.1 Later
The Problem

TabbedPage Native Behaviour

Android   - Top
iOS           - Bottom


MyTabbedPage.xaml


Solution

Add android platform-specific code in TabbedPage

Namespace

MyTabbedPage.xaml

Or C# Code Behind

MyTabbedPage.xaml.cs

Click the "Play" button to try it out.

Wow, It's Working.😍

I hope you have understood how to Change TabbedPage Top to Bottom for Android Device in Xamarin.Forms.

Thanks for reading. Please share your comments and feedback. Happy Coding 😀