SelectedItem DataTemplate not working

3 posts, 0 answers
  1. Derek Ealy
    Derek Ealy avatar
    6 posts
    Member since:
    Mar 2010

    Posted 14 May 2010 Link to this post


    I have a RadComboBox bound to an ObservableCollection<ColumnGroupViewModel> It looks like this:
                        <telerikInput:RadComboBox x:Name="cbxGroup" Margin="0,0,0,3" VerticalAlignment="Center"  
                                                  d:LayoutOverrides="Height"  Width="195" 
                                                  IsEnabled="{Binding Locked}" 
                                                  ItemsSource="{Binding Groups, Mode=TwoWay}" 
                                                  SelectedItem="{Binding SelectedGroup, Mode=TwoWay}" 
                                                  Visibility="{Binding ColumnVisibility}" IsEditable="True"
                                    <TextBlock Text="{Binding GroupName}"/> 
    Groups is the ObservableCollection and SelectedGroup is a property returning the current ColumnGroupViewModel. ColumnGroupViewModel.GroupName is the string I want to be displayed in the dropdown and also in the editable area. However when my app runs it only displays the class name for ColumnGroupViewModel in the editable area. However all the proper GroupNames are displayed in the dropdown portion of the combobox.

    I tried using SelectionBoxItemTemplate for the editable area but that just left the editable area blank. I don't see how to use a DataTemplate inside of an EditableTemplate so I'm lost here.

    Any suggestions?

    If I do get this working then my next question would be what does the RadComboBox do when the user types in a string value that doesn't match a GroupName in the ObservableCollection? Preferably I would like to catch this before an error and create a new ColumnGroupViewModel to add in the ObservableCollection with the newly specified value from the editable portion of the combobox.

    Thanks, Derek

  2. Konstantina
    Konstantina avatar
    2332 posts

    Posted 15 May 2010 Link to this post

    Hello Derek,

    To display the proper member value in the editable area you need to set the TextSearch.TextPath attached property:

    As for the second question, when you type text that does not match an item in the collection, the Text property will contain the typed text, but the SelectedItem/SelectedValue will be null. Since the Text property is updated in every key stroke, you will not be able to create new items without assigning a "create" key. Please, see the attached example for more info.

    Kind regards,
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Derek Ealy
    Derek Ealy avatar
    6 posts
    Member since:
    Mar 2010

    Posted 17 May 2010 Link to this post

    TextSearch.TextPath worked great.


Back to Top