RadComboBox type ahead not working when using a ContainerBindingCollection / DataTemplate

3 posts, 0 answers
  1. Stephen
    Stephen avatar
    43 posts
    Member since:
    Apr 2012

    Posted 15 Aug 2012 Link to this post

    I have a combo box that is bound to a collection.  There are some items in that collection that I do not want to be visible in the combo box.  I am using a ContainerBindingCollection / DataTemplate to accomplish this and it works great.  The problem is that type ahead doesn't work.  Could you please let me know how I can resolve this?  My guess is that type ahead is based on DisplayMemberPath, which isn't used in this scenario.

    Here is the code for my ContainerBindingCollection and DataTemplate:
    <telerik:ContainerBindingCollection x:Name="UserItemBindings">
        <telerik:ContainerBinding Binding="{Binding VisibleState, Mode=TwoWay}" PropertyName="Visibility" />
    </telerik:ContainerBindingCollection>
    <DataTemplate x:Key="ComboBoxVisibilityTemplate" telerik:ContainerBinding.ContainerBindings="{StaticResource UserItemBindings}">
        <TextBlock Text="{Binding DropDownEntry}" />
    </DataTemplate>

    Here is the code for my combo box:
    <telerik:RadComboBox x:Name="rcbxLocationFavorite"
      Width="200"
      Height="25"
      VerticalAlignment="Center"
      ClearSelectionButtonVisibility="Visible"
      ItemTemplate="{StaticResource ComboBoxVisibilityTemplate}"
      SelectedValuePath="EntryStringId"
      TextSearchMode="Contains"
      ToolTipService.Placement="Top" />

  2. Stephen
    Stephen avatar
    43 posts
    Member since:
    Apr 2012

    Posted 15 Aug 2012 Link to this post

    I found something I thought would work, but it fixes one problem and causes another.  Using this code for the button makes type ahead work.  The problem it that when you do type ahead, it will consider those hidden values as possible.  So, if you have something hidden and type the first letter of it, it will show up as the selected item (but not visible in the drop down list).

    <telerik:RadComboBox x:Name="rcbxLocationFavorite"
      Width="200"
      Height="25"
      VerticalAlignment="Center"
      ClearSelectionButtonVisibility="Visible"
      ItemTemplate="{StaticResource ComboBoxVisibilityTemplate}"
      SelectedValuePath="DropDownEntry"
      telerik:TextSearch.TextPath="DropDownEntry"
      TextSearchMode="Contains"
      ToolTipService.Placement="Top" />
  3. DevCraft banner
  4. Stephen
    Stephen avatar
    43 posts
    Member since:
    Apr 2012

    Posted 15 Aug 2012 Link to this post

    I figured out a solution for this.  I added another property to my ContainerBindingCollection, which disables the item.  So, the one property stops it from being selected and the second stops it from being seen.

    <telerik:ContainerBindingCollection x:Name="UserItemBindings">
      <telerik:ContainerBinding Binding="{Binding Show, Mode=TwoWay}" PropertyName="IsEnabled" />
      <telerik:ContainerBinding Binding="{Binding VisibleState, Mode=TwoWay}" PropertyName="Visibility" />
    </telerik:ContainerBindingCollection>
    <DataTemplate x:Key="ComboBoxVisibilityTemplate"
      telerik:ContainerBinding.ContainerBindings="{StaticResource UserItemBindings}">
    <TextBlock Text="{Binding DropDownEntry}" />
Back to Top