This is a migrated thread and some comments may be shown as answers.

SingleMode with border and close button

3 Answers 100 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Philippe
Top achievements
Rank 1
Philippe asked on 27 Jul 2019, 04:19 PM

Hello,

On an AutoCompleteBox, :

- MultipleMode : The selection have a border and a close button. It's really easy to remove the selection. But the number of selection is not limited.

- SingleMode : The selection have no border and close button.

Is it possible to have SingleMode with the border and the close button ? Or is it possible to limit the selection quantity of MultipleMode to 1 ?

Best regards

Philippe

3 Answers, 1 is accepted

Sort by
0
Vladimir Stoyanov
Telerik team
answered on 31 Jul 2019, 04:06 PM
Hello Philippe,

Please, check the following example from our SDK repository that demonstrates how to add a button that clears the current SelectedItem when the SelectionMode is Single - the same behavior as the button visualized inside the boxes of the selected items with Multiple selection:
https://github.com/telerik/xaml-sdk/tree/master/AutoCompleteBox/SingleSelectionModeWithClearButton

Please, let us know if that is the desired functionality or visualizing the item inside a box is also required.

Regards,
Vladimir Stoyanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Philippe
Top achievements
Rank 1
answered on 31 Jul 2019, 07:08 PM

Hello Vladimir,

Thank you for your answer.
I'm really disapointed. AutoCompleteBox in MultipleMode is beautiful and easy to code.
In this example, i need to manage all manually and the cross is on the right.

Is it possible, in MultipleMode to limit the quantity of selected item to 1 ?

Best regards

Philippe

0
Vladimir Stoyanov
Telerik team
answered on 05 Aug 2019, 04:31 PM
Hello Philippe,

I am afraid that by design in single selection, the selected item is displayed in the RadWaterMarkTextBox element. That said, I can suggest leaving the SelectionMode to Mulitple and handling the SelectionChanged event in a similar manner:
private void AutoCompleteBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var autoCompleteBox = sender as RadAutoCompleteBox;
            var count = 0;
            foreach (var item in autoCompleteBox.SelectedItems)
            {
                count++;
            }
 
            if (count == 1)
            {
                var watermarkTextBox = autoCompleteBox.ChildrenOfType<RadWatermarkTextBox>().FirstOrDefault();
                watermarkTextBox.Visibility = Visibility.Collapsed;
            }
            else if(count == 0)
            {
                var watermarkTextBox = autoCompleteBox.ChildrenOfType<RadWatermarkTextBox>().FirstOrDefault();
                watermarkTextBox.Visibility = Visibility.Visible;
            }
        }

This way, if there is a SelectedItem, the RadWatermarkTextBox will be collapsed and it will be shown only when the item is unselected. 

Please, give this approach a try and let me know how it goes.

Regards,
Vladimir Stoyanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
AutoCompleteBox
Asked by
Philippe
Top achievements
Rank 1
Answers by
Vladimir Stoyanov
Telerik team
Philippe
Top achievements
Rank 1
Share this question
or