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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Leveraging MVVM frameworks in conjunction w/ SyncFusion

Thread ID:





145742 Jul 5,2019 06:00 PM UTC Jul 6,2019 01:17 PM UTC Xamarin.Forms 1
Tags: SfPopup
John Livermore
Asked On July 5, 2019 06:00 PM UTC

Hi, we are using the lightweight FreshMVVM framework in our Xamarin app.  I am playing with the SfPopup control, and see you must open it with the .Show0 method.  However, in a MVVM framwork, the view model is loosely coupled to the underlying View, so the controls (by name) are not available.  How can the Show() method be invoked on your control through a property setting in the ViewModel?  

So the property might be...

public bool ShowDialog{get;set;}

And when it's time to show the dialog, the model just sets ShowDialog to 'true', and the dialog appears (thusly invoking the Show() method)?

And, it's an antipattern to locate the control in the view model to call Show(), so any solution that includes something like that isn't workable for us.

How can we use a MVVM framework with your popup, and more generally for all your controls?

Subburaj Pandian Veluchamy [Syncfusion]
Replied On July 6, 2019 01:17 PM UTC

Hi John, 
Thank you for contacting Syncfusion support. 
We have checked your requirement of displaying the popup using a Boolean and you can set SfPopupLayout.IsOpen as true to display the popup view. Based on your requirement we have prepared a sample in FreshMvvm to display the popup view from the model page using the SfPopupLayout.IsOpen property. 
Please refer the following code,
//// Model code: 
public class FirstPageModel : FreshBasePageModel 
               public Command<SfPopupLayout> OpenAlertDialog { getset; } 
               public FirstPageModel() 
                              this.OpenAlertDialog = new Command<SfPopupLayout>(this.DisplayAlert); 
               private void DisplayAlert(SfPopupLayout popupLayout) 
                              popupLayout.IsOpen = true;                                      
//// Xaml code: 
            <popuplayout:SfPopupLayout x:Key="AlertDialog"> 
                    <popuplayout:PopupView ShowHeader="False" 
                                           HeightRequest="120" > 
                                <Grid BackgroundColor="White" Padding="15,20,0,0"> 
                                    <Label FontSize="16"  BackgroundColor="White" TextColor="Gray" Text="Discard draft?"/> 
        <ScrollView x:Name="parentLayout"> 
            <StackLayout Orientation="Vertical" Spacing="20" Padding="20" > 
                <Button x:Name="Alert"                         
                        Command="{Binding OpenAlertDialog}" 
                        CommandParameter="{StaticResource AlertDialog}" /> 
We have attached the sample for your reference, 
Subburaj Pandian V  


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

Live Chat Icon For mobile
Live Chat Icon