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. Image for the cookie policy date

Display popup in MVVM

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.

8 Replies

PK Pradeep Kumar Balakrishnan Syncfusion Team 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 



ØG Øystein Günther 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;
        }


PK Pradeep Kumar Balakrishnan Syncfusion Team 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 
 



PK Pradeep Kumar Balakrishnan Syncfusion Team 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 



ØG Øystein Günther 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?


SP Subburaj Pandian Veluchamy Syncfusion Team 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 
 



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

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


SP Subburaj Pandian Veluchamy Syncfusion Team 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  


Loader.
Up arrow icon