Xamarin Forms Creating Your Own Custom Dialog

Posted by seven.srikanth@gmail.com at 28-05-2018 17:25:49 in Article



 Overview

Sometimes the existing dialogs from Xamarin.forms does not conforms to what we need like custom dialog which contains some entry and ok cancel button or perhaps a listview inside a dialog that may contain complex UI, existing libraries like in this link and acr dialog doesnt give us what exactly we want in a dialog. And worst we will resort with custom renderers to achieve this. So i made a custom dialog made purely in xaml without custom renderer. Yes you read it right its pure xaml, you can check the full source code here.

How to use

Just copy the source implementation of PopUpDialogView just like you see in the screen below, you can customize it to conform with your design Or may add another animation transition during show and hide. Adding PopUpDialogView in your page is simple, you will  need to add a Grid Layout without rows and columns, please take a look at the code below. -
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:CustomPopupDialog"
xmlns:views="clr-namespace:CustomPopupDialog.Views;assembly=CustomPopupDialog"
x:Class="CustomPopupDialog.MainPage"
Title="Custom Dialog Test">
<ContentPage.Content>
<Grid>
<Button VerticalOptions="End" x:Name="BtnShowDialog" Text="ShowDialog"></Button>
<views:PopUpDialogView x:Name="PopUpDialog" HeaderTitle="Test Dialog">
<!--CREATE YOUR BINDABLE ELEMENTS HERE BASE FROM THE PAGES VIEW MODELS-->
<Label Text="This is a content"></Label>
</views:PopUpDialogView>
</Grid>
</ContentPage.Content>
</ContentPage>
-

Wrapping Up

You can check the full source here, For more about Xamarin.Forms you can always check their site and if you want something fresh you can check their blog. If you have questions please feel free to comment just below this article.
Original Author: 

Tags: Xamarin Forms Creating Your Own Custom Dialog



0 Comments
Login to comment.

Recent Comments

Be the first to Comment. You can ask a Query or Share your toughts or Just say thanks.