Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
148071 | Oct 4,2019 04:33 AM UTC | Nov 1,2019 03:03 PM UTC | Xamarin.Forms | 17 |
![]() |
Tags: SfPopup |
[XAML]
<ContentPage.Content>
<sfPopupLayout:SfPopupLayout x:Name="popupLayout" Closing="PopupLayout_Closing">
<sfPopupLayout:SfPopupLayout.PopupView>
<sfPopupLayout:PopupView AnimationMode="None" AcceptButtonText="Submit">
<sfPopupLayout:PopupView.ContentTemplate>
<DataTemplate x:Name="template">
<StackLayout>
<border:SfBorder HorizontalOptions="FillAndExpand" HasShadow="True" ShadowColor="Gray"
BorderColor="LightGray" Margin="5,5,5,0" BorderWidth="1"
BackgroundColor="White"
CornerRadius="9,9,9,9">
<StackLayout Padding="10,10,10,10">
<Entry x:Name="firstName" Text="{Binding labelFirstName}" Placeholder="Enter First Name" TextChanged="FirstName_TextChanged">
</Entry>
<Entry x:Name="lastName" Text="{Binding labelLastName}" Placeholder="Enter Last Name" TextChanged="LastName_TextChanged"></Entry>
</StackLayout>
</border:SfBorder>
</StackLayout>
</DataTemplate>
</sfPopupLayout:PopupView.ContentTemplate>
</sfPopupLayout:PopupView>
</sfPopupLayout:SfPopupLayout.PopupView>
<sfPopupLayout:SfPopupLayout.Content>
<StackLayout>
<Button BackgroundColor="Gray" Text="ClickToShow" Grid.Row="0" Clicked="Button_Clicked"></Button>
<Button Text="ClickToNavigate" Clicked="Button_Clicked_1"></Button>
</StackLayout>
</sfPopupLayout:SfPopupLayout.Content>
</sfPopupLayout:SfPopupLayout>
</ContentPage.Content>
[CS] ViewModel viewModel;
private StackLayout stack;
public RootViewPopup()
{
InitializeComponent();
viewModel = new ViewModel();
this.BindingContext = viewModel;
stack = popupLayout.PopupView.ContentTemplate.CreateContent() as StackLayout;
}
private void PopupLayout_Closing(object sender, Syncfusion.XForms.Core.CancelEventArgs e)
{
viewModel.labelFirstName = (stack as StackLayout).FindByName<Xamarin.Forms.Entry>("firstName").Text;
viewModel.labelLastName = (stack as StackLayout).FindByName<Xamarin.Forms.Entry>("lastName").Text;
}
private async void Button_Clicked(object sender, EventArgs e)
{
if (popupLayout.PopupView.ContentTemplate != template)
{
popupLayout.PopupView.ContentTemplate = template;
}
popupLayout.PopupView.HeaderTitle = "First Popup";
popupLayout.Show();
}
private void FirstName_TextChanged(object sender, TextChangedEventArgs e)
{
(stack as StackLayout).FindByName<Xamarin.Forms.Entry>("firstName").Text = e.NewTextValue;
}
private void LastName_TextChanged(object sender, TextChangedEventArgs e)
{
(stack as StackLayout).FindByName<Xamarin.Forms.Entry>("lastName").Text = e.NewTextValue;
}
private async void Button_Clicked_1(object sender, EventArgs e)
{
await Navigation.PushAsync(new SecondPagePopup(popupLayout,stack));
} |
[XAML]
<sfPopup:SfPopupLayout xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:sfPopup="clr-namespace:Syncfusion.XForms.PopupLayout;assembly=Syncfusion.SfPopupLayout.XForms"
x:Class="Popup_Demo.PopupPage">
<sfPopup:SfPopupLayout.PopupView>
<sfPopup:PopupView>
<sfPopup:PopupView.ContentTemplate>
……
</sfPopup:PopupView.ContentTemplate>
</sfPopup:PopupView>
</sfPopup:SfPopupLayout.PopupView>
</sfPopup:SfPopupLayout>
[.CS] public partial class PopupPage : SfPopupLayout
{
…….
}
public partial class MainPage : ContentPage
{
PopupPage popuppage;
public MainPage()
{
InitializeComponent();
}
private void Button_Clicked(object sender, EventArgs e)
{
popuppage.Show();
}
…….
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.