Get the RadComboBox Text of an editable combobox

10 posts, 0 answers
  1. danparker276
    danparker276 avatar
    389 posts
    Member since:
    Aug 2010

    Posted 21 Feb 2012 Link to this post

    UPDATE: This only happens when I'm setting the combobox to a Non Virtualizing Stack Panel and filter is enabled:
    UPDATE: Version 2012.1.221.1050 and the other 2012 fail.  Version 2011.3.1413.1050 works.

    I'm almost positive this used to work and a recent update has changed things.
    When I tab out of an editable combo box, I want to get the text value in the combo box even if it isn't a selected item.

    <telerik:RadComboBox x:Name="myCombo" OpenDropDownOnFocus="False" Margin="5 0 0 0"
            IsReadOnly="False" LostFocus="myCombo_LostFocus"
            SelectionChanged="myCombo_SelectionChanged"
            ClearSelectionButtonVisibility="Visible" ClearSelectionButtonContent="Clear"
            Width="80" IsEditable="True">


    private void myCombo_LostFocus(object sender, RoutedEventArgs e)
    {
        //I Don't get the correct
        string myText= (myCombo.Text ?? "").Trim();
        
    }

    When I go to the lost focus, there is nothing in the .Text even if I type something in the combobox.

    UPDATE This is in my init:
    public SilverlightControl1()
    {
        InitializeComponent();
        this.rcMatterId.ItemsPanel = this.Resources["NotvirtualizingStackPanel"] as ItemsPanelTemplate;
        rcMatterId.IsFilteringEnabled = true;
    }

    UPDATE: This is in my xaml
    <UserControl.Resources>
        <ItemsPanelTemplate x:Key="virtualizingStackPanel">
            <VirtualizingStackPanel />
        </ItemsPanelTemplate>
        <ItemsPanelTemplate x:Key="NotvirtualizingStackPanel">
        </ItemsPanelTemplate>
    </UserControl.Resources>

    This only fails to get the text value when the Update mentioned is set.  This is only in the new version of telerik controls.
  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 27 Feb 2012 Link to this post

    Hello Dan,

    We've managed to reproduce this issue and we will investigate the reasons for it.  I will write here as soon as we have a result.

    All the best,
    Yana
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. DevCraft banner
  4. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 19 Apr 2012 Link to this post

    Hello Dan,

    We've logged this issue in our public issue tracking system, you can vote for it and track its progress here. We will do our best to fix it for the Q2 release or shortly after.

    We are sorry for the caused inconvenience.

    All the best,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  5. Oleg
    Oleg avatar
    42 posts
    Member since:
    Oct 2011

    Posted 17 Dec 2012 Link to this post

    Hi there!

    I have this issue with Telerik.Windows.Controls.DLL of version 2012.3.1017.1050. My RadComboBox loses its text i've entered after LostFocus, if it doesnt fit any item in the list.

    Here is my xaml:

    <telerik:RadComboBox Name="InputComboBox" CanKeyboardNavigationSelectItems="True" StaysOpenOnEdit="True"  Grid.Column="1" IsEditable="True" ItemsSource="{Binding PossibleEmailRecipients}"
                                                 Margin="5" KeyDown="InputComboBoxKeyDown" Padding="5" FontFamily="{StaticResource ContentFontFamily}"
                                                 CanAutocompleteSelectItems="True" OpenDropDownOnFocus="True"
                                                 FontSize="{StaticResource SmallFontSize}" telerik:TextSearch.TextPath="SearchString" TextSearchMode="Contains">
                                <telerik:RadComboBox.ItemTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <ntcControls:Avatar PopupEnabled="False" DisplayMode="ExtraSmallWithName"  User="{Binding User}" Foreground="{StaticResource BlackBrush}" Margin="5,0,0,0" VerticalAlignment="Center" Visibility="{Binding User, Converter={StaticResource NullVisibleConverter}, ConverterParameter='invert'}"/>
                                            <TextBlock Foreground="{StaticResource BlackBrush}" Text="{Binding Email}" VerticalAlignment="Center" Margin="5,0,0,0" Visibility="{Binding User, Converter={StaticResource NullVisibleConverter}}"/>
                                        </StackPanel>
                                    </DataTemplate>
                                </telerik:RadComboBox.ItemTemplate>
                            
                               
                            </telerik:RadComboBox>

    In the InputComboBoxKeyDown event happens this:
    if (e.Key == Key.Enter)
    {
        TryAddRecipient();
    }
  6. Oleg
    Oleg avatar
    42 posts
    Member since:
    Oct 2011

    Posted 17 Dec 2012 Link to this post

    Btw my question is - how can I prevent it and keep the text in the combobox?


  7. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 19 Dec 2012 Link to this post

    Hi Dan,

    I am afraid that the ComboBox is designed in such a way that it does not preserve the text in this case (when filtering is enabled and the text does not match any item in the dropdown).

    We're sorry for the inconvenience.

    Regards,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  8. Oleg
    Oleg avatar
    42 posts
    Member since:
    Oct 2011

    Posted 21 Dec 2012 Link to this post

    I am not Dan :D But it's okay :)))

    In your samples there is a Combobox with the exactly the same item template structure as I need. And it works the way I need it - but I dont know what's different in there... What do you mean with "filtering"? Autocomplete function? How can I disable this filter stuff to make the combobox keep the text?
  9. Oleg
    Oleg avatar
    42 posts
    Member since:
    Oct 2011

    Posted 21 Dec 2012 Link to this post

    <telerik:RadComboBox IsFilteringEnabled="False" Name="InputComboBox" CanKeyboardNavigationSelectItems="True" StaysOpenOnEdit="True"  Grid.Column="1" IsEditable="True"
                                               ItemsSource="{Binding PossibleEmailRecipients}" Margin="5" KeyDown="InputComboBoxKeyDown" Padding="5" FontFamily="{StaticResource ContentFontFamily}"
                                               CanAutocompleteSelectItems="True" OpenDropDownOnFocus="True"
                                               FontSize="{StaticResource SmallFontSize}" telerik:TextSearch.TextPath="SearchString" TextSearchMode="Contains">

    This is the xaml code of my combobox - Filter ist disabled. But it still doesnt work
  10. Oleg
    Oleg avatar
    42 posts
    Member since:
    Oct 2011

    Posted 21 Dec 2012 Link to this post

    I've found the problem. The behaviour is correct, if I remove this property:  TextSearchMode="Contains"

  11. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 21 Dec 2012 Link to this post

    Hi Oleg,

    I am sorry for the mistake.

    I am glad that you've managed to find a solution.

    Kind regards,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
DevCraft banner