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

Select item on tap.

Hi,

How can I make a function to select an item from a picker by tapping on it. As of right now, I use "Picker.SelectionChanged" to scroll through items and then I have to press OK in my footer to confirm selection. I want to remove footer and just use simple tap on item to select item and hide picker.

Example code:

            Picker.SelectionChanged += (sender, args) =>
            {
                var item = Picker.SelectedItem;
                _code = _deptList.Where(d => d.DeptDescription == item).Select(d => d.Code).First();
                _department = _deptList.Where(d => d.DeptDescription == item).Select(d => d.DeptDescription).First();

                // This should only be used when I tap on item.
                currentTable.ItemsSource = GetProductsList(_code);
                compareTable.ItemsSource = GetProductsList(_code);
                totalTable.ItemsSource = GetProductsList(_code);
                PickerButton.Text = _department;
                Picker.IsOpen = false;
            };

3 Replies

PA Paul Anderson S Syncfusion Team December 13, 2018 11:37 AM UTC

Hi Team, 
 
Greetings from Syncfusion. 
 
Query: “I want to remove footer and just use simple tap on item to select item and hide picker.” 
 
We have analyzed the reported query, for removing the footer, you can use the ShowFooter property as false. Initially the Picker will display the items to 4 or 5 based on the Picker height and you can select the item by tap/scroll and this will set the items as SelectedItem triggering the SelectionChanged event. In that you can set the IsOpen API  as false for closing the SfPicker.  
 
We have prepared a sample by using a ShowFooter property. Please have the sample from the following link 
 
 
Please let us know if you have any other concern. 
 
Regards, 
Paul Anderson 



RS Retail Solutions December 19, 2018 11:44 AM UTC

Hi,


Problem with that solution is that when you have 20 items in your picker, you can't scroll through all of them and select an item that you need, because SelectionChanged stops as soon as you release picker.

Another thing that I wanted to ask is: Can you change the color of the footer? I would like to at least be able to change color of the OK and Cancel buttons to match my color scheme.



Attachment: Screenshot_20181219113926_6b115f12.zip


DR Dhanasekar R Syncfusion Team December 20, 2018 12:59 PM UTC

Hi Team, 
  
Thanks for your update. 
  
Query 1: “when you have 20 items in your picker, you can't scroll through all of them and select an item that you need” 
  
As per the implementation of SfPicker, SelectedItem will be changed when the scrolling is completed. So this is the reason why picker is closed when the SelectionChanged is called.  In order to avoid closing picker in selection changed event, you can close the picker of FooterView and set IsOpen as false in buttons in the FooterView. 
  
Query 2: “Can you change the color of the footer” 
  
This can be achieved by using a FooterView. We have modified the provided sample by using the FooterView for SfPicker. Please have the sample from the following link 
  
  
In this sample we have used two buttons as OK and Cancel in the FooterView.  In this button click event you may close the SfPicker by setting IsOpen as false and you can give the Button color based on your application color scheme. 
  
Regards,  
Dhanasekar 
 


Loader.
Live Chat Icon For mobile
Up arrow icon