- Home
- Forum
- Xamarin.Forms
- Show Popup without clicking a button
Show Popup without clicking a button
i have this code
ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:border="clr-namespace:Syncfusion.XForms.Border;assembly=Syncfusion.Core.XForms"
xmlns:inputLayout="clr-namespace:Syncfusion.XForms.TextInputLayout;assembly=Syncfusion.Core.XForms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:button="clr-namespace:Syncfusion.XForms.Buttons;assembly=Syncfusion.Buttons.XForms"
xmlns:syncfusion="clr-namespace:Syncfusion.SfBusyIndicator.XForms;assembly=Syncfusion.SfBusyIndicator.XForms"
xmlns:sfPopup="clr-namespace:Syncfusion.XForms.PopupLayout;assembly=Syncfusion.SfPopupLayout.XForms"
x:Class="WGBSync.Views.Register" BackgroundImage="bg.png" NavigationPage.HasBackButton="False" NavigationPage.HasNavigationBar="False">
<sfPopup:SfPopupLayout x:Name="popupme" >
<sfPopup:SfPopupLayout.Padding>
<OnPlatform x:TypeArguments="Thickness">
<On Platform="iOS" Value="0, 20, 0, 0" />
</OnPlatform>
</sfPopup:SfPopupLayout.Padding>
<sfPopup:SfPopupLayout.Content>
<StackLayout x:Name="mainLayout">
<Grid>
</Grid>
</sfPopup:SfPopupLayout.Content>
</sfPopup:SfPopupLayout >
and this c# code
public void popup(string message, int type, string header)
{
try
{
contentTemplateView = new DataTemplate(() =>
{
popupContent = new Label
{
Text = message,
TextColor = type == 1 ? Color.Green : Color.Red,
BackgroundColor = Color.White,
HorizontalTextAlignment = TextAlignment.Center,
};
return popupContent;
});
headerTemplateView = new DataTemplate(() =>
{
popupheader = new Label
{
Text = header,
FontAttributes = FontAttributes.Bold,
BackgroundColor = type == 1 ? Color.Green : Color.Red,
FontSize = 16,
TextColor = Color.White,
HorizontalTextAlignment = TextAlignment.Center,
VerticalTextAlignment = TextAlignment.Center
};
return popupheader;
});
popupme.PopupView.HeaderTemplate = headerTemplateView;
popupme.PopupView.ContentTemplate = contentTemplateView;
popupme.PopupView.AppearanceMode = AppearanceMode.OneButton;
popupme.PopupView.AnimationMode = AnimationMode.Zoom;
popupme.PopupView.AcceptButtonText = "OK";
popupme.Show();
}
catch(Exception ex)
{
return;
}
}
i want to call popup like this on registration success popup("Registration Successful",1,"Sucess") on the click of register button.
am getting noSuchmethodError
SIGN IN To post a reply.
2 Replies
TE
Temitope
March 4, 2019 01:02 PM UTC
please help
SP
Subburaj Pandian Veluchamy
Syncfusion Team
March 5, 2019 11:25 AM UTC
Hi Temitope,
Thank you for contacting Syncfusion support.
Based on the provided information, your requirement of “Showing Popup layout as a content in the page without any click operation” can be achieved by setting the Popup layout as content in the concern page. And if your requirement is to render the Popup without any function like Button click, you can call Show method in the Popup with the delay.
Please refer the following code example,
|
[C#]
private async void showpopup()
{
await Task.Delay(1000);
popupLayout.Show();
}
|
We have prepared sample by setting Popup as content in the ContentPage and shown the Popup directly without any click operation. Please find the sample by the following link,
Sample link: PopupDefaultOpen_Sample
We hope this helps. Please let us know, if you have any query.
Regards,
Subburaj Pandian V
Subburaj Pandian V
SIGN IN To post a reply.
- 2 Replies
- 2 Participants
-
TE Temitope
- Mar 4, 2019 09:35 AM UTC
- Mar 5, 2019 11:25 AM UTC