We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Display popup in MVVM

Thread ID:

Created:

Updated:

Platform:

Replies:

142943 Feb 26,2019 02:02 PM UTC Mar 8,2019 04:41 AM UTC Xamarin.Forms 8
loading
Tags: SfPopup
Øystein Günther
Asked On February 26, 2019 02:02 PM UTC

I am not able to get this to work. Would it be possible to post a full example showcasing this?

What I am aiming for is a popup containing numeric buttons (0-9). When clicked, perform a command to the viewmodel and send the the respective number as a command parameter. Each time the viewmodel receives a number, it will do something like PinCode += value; When finished, click ok button (also in the popup) and trigger some other command that will process all numbers entered in the viewmodel.

Pradeep Kumar Balakrishnan [Syncfusion]
Replied On February 27, 2019 02:39 PM UTC

Hi Oystein , 
 
Thank you for contacting Syncfusion support. 
 
Currently, we are validating you requirement, we will prepare the sample in MVVM to meet your requirement and we will update the sample on March 1, 2019. We appreciate your patience until then.  
 
Regards, 
Pradeep Kumar B 


Øystein Günther
Replied On February 28, 2019 12:20 PM UTC

Thanks, I am looking forward to trying that out! As of this writing I got something working, but it's not 100% MVVM and actually quite strange. Initially I struggled setting the BidingContext, sorted that out and was able to show/hide the popup via databinding the "IsOpen" property. But solution was not stable. 

Problem was when navigating to another page and then returning back to a new instance of this page, the popup opens, but when closed it fails to open again. I explicitly set the bounded DisplayPopup property to false in the ViewModel, but somehow I get this strange behaviour. So in a desperate moment I removed the IsOpen="{Binding DisplayPopup}" from the XAML (which I don't want to do), set the "IsOpen" to false when leaving the page and check if it is true when trying to show the popup, via a standard click event. This is really ugly and a hack that I want to avoid. 

Part of my XAML:
       <sfPopup:SfPopupLayout x:Name="popupLayout">
        <sfPopup:SfPopupLayout.PopupView>
            <sfPopup:PopupView x:Name="pop"
                               WidthRequest="220"
                               HeightRequest="280"
                               ShowFooter="false"
                               ShowHeader="false">
                <sfPopup:PopupView.ContentTemplate>
                    <DataTemplate>
                        <Grid                                                                       

Events that needs to be removed:
// Button click event
void Handle_Clicked(object sender, System.EventArgs e)
        {
            if (popupLayout.IsOpen)
                popupLayout.IsOpen = false;
            popupLayout.IsOpen = true;
        }

// ContentPage
        protected override void OnDisappearing()
        {
            popupLayout.IsOpen = false;
        }

Pradeep Kumar Balakrishnan [Syncfusion]
Replied On March 4, 2019 02:16 AM UTC

Hi Øystein   
 
Sorry for the delay, 
 
We have not prepared the sample yet. We will prepare sample and update on today March 4, 2019. We appreciate your patience until then. 
 
Regards, 
Pradeep Kumar B 
 


Pradeep Kumar Balakrishnan [Syncfusion]
Replied On March 5, 2019 05:15 PM UTC

Hi Øystein, 
 
Sorry for the delay. 
 
We have prepared the sample to show popup view in MVVM and also we have covered the mentioned requirement. And please find the sample in following link. 
 
 
Regards, 
Pradeep Kumar B 


Øystein Günther
Replied On March 6, 2019 08:03 AM UTC

Thanks for the demo! But, I think you forgot to add a file or two. I am not able to compile because I am missing "OrderInfo" and "OrderInfoRepository".
Could you check and post an update?

Subburaj Pandian Veluchamy [Syncfusion]
Replied On March 7, 2019 06:49 AM UTC

Hi Øystein, 
  
Thank you for the update. 
 
We have modified the sample to “Show popup view in MVVM”, please find the modified sample by the following link, 
 
 
Please check the sample and let us know if you have any query. 
 
Regards,
Subburaj Pandian V 
 


Øystein Günther
Replied On March 7, 2019 11:54 AM UTC

Thank you for the update! I will give it a try :-)

Subburaj Pandian Veluchamy [Syncfusion]
Replied On March 8, 2019 04:41 AM UTC

Hi Øystein, 
 
Thank you for the update. Please check the sample and let us know, if you have any query.  
 
Regards,
Subburaj Pandian V  


CONFIRMATION

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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;