Binding IsOpen from viewModel not working.

Hi,

I tried to bind IsOpen from ViewModel It works just for one time look at this example :
XMAL
<syncfusion:SfPicker x:Name="MonthPicker" ItemsSource="{Binding ListMonths}" DisplayMemberPath="MonthString"  IsEnabled="True"
                                 IsOpen="{Binding IsOpen}"
                                 HorizontalOptions="Center"
                                 PickerHeight="300"
                                 PickerMode="Dialog"
                                 PickerWidth="280"
                                 HeaderText="Select a month"
                                 ShowHeader="True"
                                 ShowFooter="True"
                                 HeaderBackgroundColor="#2499ce"
                                 ColumnHeaderTextColor="White"
                                 SelectedItemTextColor="#2499ce"
                                 UnSelectedItemTextColor="Black"
                                 VerticalOptions="Center">
 </syncfusion:SfPicker>
<StackLayout Grid.Row="0" Orientation="Horizontal" Margin="5,0,0,-5" HorizontalOptions="Start" >
         <StackLayout.GestureRecognizers>
                <TapGestureRecognizer  Command="{Binding MonthTapped}" />
         </StackLayout.GestureRecognizers>
         <Label Text="{Binding CurrentMonth.MonthString}" HorizontalOptions="Start" TextColor="Black" FontSize="Medium"/>
         <Image x:Name="imgTriangel"  WidthRequest="12" HeightRequest="12" HorizontalOptions="End"/>
 </StackLayout>

ViewModel:
// property 
private bool _isOpen=false;
public bool IsOpen
{
   get {return _isOpen;}
   set{_isOpen=value;OnPropertyChanged("IsOpen");}
}

//command 
MonthTapped= new Command((p) => {
     IsOpen=true;
});

what happened when the command has executed for the first time the picker shows up and works fine if I close it and execute the command again nothing happens.
I put a breakpoint at "get" part of the IsOpen property, it hits only first time.

Thanks in advance .


5 Replies

PA Paul Anderson S Syncfusion Team October 5, 2018 06:09 AM UTC

Hi Mohammed, 
 
Greetings from Syncfusion. 
 
We have created a sample based on your code snippet provided and we are not able to replicate the issue at our end with SfPicker control. We have attached the sample created in the below link. 
 
 
Please check the sample and if it differs from your sample can you please replicate for us so that we can get the reason for the issue and help you. Also let us know in which platform the issue occurs. 
 
Regards, 
Paul Anderson 



MO Mohammed October 9, 2018 01:53 PM UTC

After I compared your sample with my code I solved the issue by add mode two-way  to the "IsOpen" 

old code:
<syncfusion:SfPicker x:Name="MonthPicker" ItemsSource="{Binding ListMonths}" DisplayMemberPath="MonthString"  IsEnabled="True"
                                 IsOpen="{Binding IsOpen}"
                                 HorizontalOptions="Center"
                                 PickerHeight="300"
                                 PickerMode="Dialog"
                                 PickerWidth="280"
                                 HeaderText="Select a month"
                                 ShowHeader="True"
                                 ShowFooter="True"
                                 HeaderBackgroundColor="#2499ce"
                                 ColumnHeaderTextColor="White"
                                 SelectedItemTextColor="#2499ce"
                                 UnSelectedItemTextColor="Black"
                                 VerticalOptions="Center">
 </syncfusion:SfPicker>

replaced with :

<syncfusion:SfPicker x:Name="MonthPicker" ItemsSource="{Binding ListMonths}" DisplayMemberPath="MonthString"  IsEnabled="True"
                                 IsOpen="{Binding IsOpen,Mode=TwoWay}"
                                 HorizontalOptions="Center"
                                 PickerHeight="300"
                                 PickerMode="Dialog"
                                 PickerWidth="280"
                                 HeaderText="Select a month"
                                 ShowHeader="True"
                                 ShowFooter="True"
                                 HeaderBackgroundColor="#2499ce"
                                 ColumnHeaderTextColor="White"
                                 SelectedItemTextColor="#2499ce"
                                 UnSelectedItemTextColor="Black"
                                 VerticalOptions="Center">
 </syncfusion:SfPicker>

thanks


PA Paul Anderson S Syncfusion Team October 10, 2018 05:00 AM UTC

Hi Mohammed, 
  
Thanks for the update. 
  
We are glad that the issue faced has been resolved. We have planned to change the default BindingMode of IsOpen property as TwoWay and this will be done in our upcoming release. 
  
Regards, 
Paul Anderson 



MI Misael February 5, 2021 02:50 PM UTC

Hello, The issue is still present in version v18.4.0.41




RS Ruba Shanmugam Syncfusion Team February 8, 2021 05:37 AM UTC

Hi Misael,

We have validated the reported query “Binding IsOpen from ViewModel is not working” and prepared a sample using latest version 18.4.0.41 from our side. We regret to let you know that we are not able to replicate the reported issue.

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/PickerSample_IsOpen-1832858335  

Could you please share the following details which would be helpful for us to check on it and provide you solution at the earliest.

Xamarin forms version used in your application
Share the SfPicker templates
Issue reproducing video
Issue replicating sample (if possible)

Could you please check our sample and let us know if you still facing the same issue? If not, please modify our sample and revert us back with the following details which would be helpful for us to check on it and provide you the solution as soon as possible.

Regards,
Ruba Shanmugam


Loader.
Up arrow icon