UpdateTextOnLostFocus in RadComboBox doens't seem to be working

0 Answers 72 Views
ComboBox
Marko
Top achievements
Rank 2
Iron
Marko asked on 29 Jun 2023, 02:40 PM

Hello,

I have a RadComboBox that looks like this:

<telerik:RadComboBox Command="{Binding ResourceDropDownClosedCommand}"
                     ItemsSource="{Binding ResourceLookupData}"
                     AutoCompleteSelectionMode="FullMatch"
                     telerik:TextSearch.TextPath="Id"
                     AllowMultipleSelection="True"
                     UpdateTextOnLostFocus="False"
                     IsEditable="True"
                     TextSearchMode="Contains"
                     IsFilteringEnabled="True"
                     telerik:StyleManager.Theme="Windows7"
                     Grid.Column="3" Grid.Row="1">

    <telerik:RadComboBox.ItemTemplate>
                            
        <DataTemplate>
            <Grid Width="500">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="85"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>

                <TextBlock Grid.Column="0" Text="{Binding Path=Id}" />
                <TextBlock Grid.Column="1" Text="{Binding Path=ResourceDescription}"/>
            </Grid>
        </DataTemplate>
                            
    </telerik:RadComboBox.ItemTemplate>

    <telerik:RadComboBox.FilteringBehavior>
        <controlsHelpers:RadComboBoxResourceLookupFilteringBehavior />
    </telerik:RadComboBox.FilteringBehavior>

    <i:Interaction.Behaviors>
        <controlsHelpers:RadComboBoxSelectedItemsBehavior SelectedItems="{Binding SelectedResources}" />
    </i:Interaction.Behaviors>
                        
</telerik:RadComboBox>

The problem i am facing is that after the user has entered text and the RadComboBox has filtered the Items depending on the entered text, after losing focus of the RadComboBox by tabbing or clicking away, If there is no item that matches the entered text then the text is cleared, even with the UpdateTextOnLostFocus set to False.

I haven't been able to find a solution that works for me. So any suggestions would be appreciated.

Thank you

Dimitar
Telerik team
commented on 03 Jul 2023, 09:48 AM

Hi Marko, 

This property works only with the single selection mode. This is noted in our documentation: WPF ComboBox - Perform Selection Only On Lost Focus or Enter Key Press. 

Does this works for your case or do you need multiple selection? 

I am looking forward to your reply.

Marko
Top achievements
Rank 2
Iron
commented on 03 Jul 2023, 12:30 PM

Hi Dimitar,

You are correct, it only works with single selection. But we need the multiple selection.

Is there any workaround so we can have both multiple selection and have the text not clear ?

Thank you

Vladimir Stoyanov
Telerik team
commented on 06 Jul 2023, 10:03 AM

Hello Marko,

There isn't a very convenient approach for achieving the desired behavior. That said, I investigated the scenario and prepared a sample project demonstrating a possible way to obtain this result along with a video showing the tests I did on my end.

It involves maintaining the entered text in the PreviewLostKeyboardFocus event and restoring it via the UpdateText private method in the LostFocus/GotFocus events. I have also added some logic inside a custom filtering behavior to return all indexes as matches when the search text is not empty. 

Note, that I have not tested all scenarios, however I do hope that the suggested approach will serve as a good starting point for achieving the desired result. 

No answers yet. Maybe you can help?

Tags
ComboBox
Asked by
Marko
Top achievements
Rank 2
Iron
Share this question
or