Close popup method

boa tarde! Como posso fechar a mensagem pop-up por código.


5 Replies

SS Suhasini  Suresh Syncfusion Team April 2, 2018 11:34 AM UTC

Hi Jose, 
 
Thanks for contacting Syncfusion Support. 
 
You can close the popup in code behind by setting “SfPopupLayout.IsOpen = false”. 
 
We have prepared a sample to achieve your requirement, you can download the same from the below link. 
 
Regards, 
Suhasini  



JD José Donizete de Oliveira Júnior April 2, 2018 12:43 PM UTC

Bom dia, obrigado pela resposta rápida!

Eu devo estar fazendo algo errado.

este é xaml meu código:

<ContentPage xmlns = "http://xamarin.com/schemas/2014/forms"
             xmlns: x = "http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns: local = "clr-namespace: PneumaticDeveloper.Views"
             xmlns: iconize = "clr-namespace: FormsPlugin.Iconize; assembly = FormsPlugin.Iconize"
             xmlns: sfPopup = "namespace-clr: Syncfusion.XForms.PopupLayout; assembly = Syncfusion.SfPopupLayout.XForms"
             x: Name = "this"
             x: Class = "PneumaticDeveloper.Views.HomeView">
    <sfPopup: SfPopupLayout x: Name = "popupLayout">
        <sfPopup: SfPopupLayout.Content>
            <StackLayout Orientation = "Vertical">
                <Grid VerticalOptions = "FillAndExpand">
                    <ListView x: Name = "listViewFile">
                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <ViewCell>
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width = "*" />
                                            <ColumnDefinition Width = "50" />
                                        </Grid.ColumnDefinitions>
                                        <Label Grid.Column = "0" Text = "{Nome da ligação}" FontSize = "Médio" />
                                        <iconize: IconImage Grid.Column = "1" Ícone = "fa-ellipsis-v" IconColor = "Azul" IconSize = "20">
                                            <iconize: IconImage.GestureRecognizers>
                                                <Comando TapGestureRecognizer = "{Binding OnMenu, Source = {x: Referencia isto}}" CommandParameter = "{Binding.}" />
                                            </iconize:IconImage.GestureRecognizers>
                                        </ iconize: IconImage>
                                    </ Grid>
                                </ ViewCell>
                            </ DataTemplate>
                        </ListView.ItemTemplate>
                    </ ListView>
                    <local: carregando x: Name = "loading" />
                </ Grid>

                <StackLayout BackgroundColor = "Transparente">
                    <iconize: IconImage x: Name = "btnNew" Ícone = "fa-plus-circle" IconColor = "Azul" IconSize = "65" HorizontalOptions = "Centro">
                        <iconize: IconImage.GestureRecognizers>
                            <Comando TapGestureRecognizer = "{Encadernação OnNew, Source = {x: Referencia isto}}" />
                        </iconize:IconImage.GestureRecognizers>
                    </ iconize: IconImage>
                </ StackLayout>
            </ StackLayout>
        </sfPopup:SfPopupLayout.Content>
    </ sfPopup: SfPopupLayout>
</ ContentPage>

e código por trás:

classe parcial pública HomeView: ContentPage
    {
        DataTemplate templateView;
        StackLayout popupContent;
        private string projectSelected = "";

        bool private repeat = true;
        private const bool Repetir = verdadeiro;
        public ObservableCollection <MyFiles> listFiles = new ObservableCollection <MeusArquivos> ();

        HomeView público ()
        {
            InitializeComponent ();
            popupLayout.PopupView.AnimationMode = AnimationMode.SlideOnLeft;
            popupLayout.PopupView.ShowHeader = false;
            popupLayout.PopupView.ShowFooter = false;
            popupLayout.PopupView.PopupStyle.BorderThickness = 0;
            popupLayout.PopupView.PopupStyle.BorderColor = Color.FromHex ("333333");
            popupLayout.PopupView.PopupStyle.CornerRadius = 0;
            popupLayout.PopupView.WidthRequest = 250;
            popupLayout.PopupView.HeightRequest = 50;
            loading.Start ();

            listViewFile.ItemsSource = listFiles;
            listViewFile.ItemSelected + = ListViewFile_ItemSelected;

            CheckFolderAsync ();

            templateView = new DataTemplate (() =>
            {
                popupContent = new StackLayout
                {
                    BackgroundColor = Color.White,
                    Orientação = StackOrientation.Vertical,
                };

                FileOptionView fileOption = novo FileOptionView ();

                popupContent.Children.Add (fileOption);

                retornar popupContent;
            });
            popupLayout.PopupView.ContentTemplate = templateView;

        }


Desta forma sempre que eu chamo popupLayout.IsOpen = false todos os itens da tela são fechados, não apenas a janela pop-up. fecha todo o conteúdo do popupLayout.

desculpe se eu cometer um erro básico.


SS Suhasini  Suresh Syncfusion Team April 3, 2018 01:00 PM UTC

Hi Jose, 
 
Thanks for your update.  
 
We have prepared a sample as per your requirement, in which popup is closed by setting the SfPopupLayout.IsOpen = false, you can download the same from the below link. 
 
 
When popup is closed by setting the IsOpen as false, only the popup is closed. In case if you face any issue, revert us with the replication procedure to reproduce the issue to provide  you with the faster solution. 
 
Regards, 
Suhasini  



JD José Donizete de Oliveira Júnior April 3, 2018 02:26 PM UTC

Thank you, I reproduce my mistake.

To test popupLayout.IsOpen = false I inserted this line shortly after calling popupLayout.Show ().

This generates what I describe. Of course I acknowledge that the mistake is mine, for misuse.

In your sample, to reproduce is just leave like this:

private void ListViewFile_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            popupLayout.Show();

            popupLayout.IsOpen = false;
        }


I apologize for taking your time. Thank you!




SS Suhasini  Suresh Syncfusion Team April 4, 2018 11:29 AM UTC

Hi Jose, 
 
Thanks for your update.  
 
We are able to reproduce the issue “Setting SfPopupLayout.IsOpen = false immediately, after calling SfPopupLayout.Show() closes the entire contents of SfPopupLayout, provided animation is not none”, and have logged a bug report for the same, it will be fixed in 2018 Volume -1 Service Pack – 2 release which is scheduled to be rolled out by the last week of April 2018. 
 
Regards, 
Suhasini  


Loader.
Up arrow icon