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

Setting the SelectedItem

1 Answer 81 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
IPV
Top achievements
Rank 1
IPV asked on 20 Nov 2015, 07:53 PM

I have an AutoCompleteBox defined like this:

<telerik:RadAutoCompleteBox Grid.Row="4" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,3,6,3"
     WatermarkContent="Interviewer's name..."
     x:Name="acb_Interviewer"
     TextSearchMode="Contains"
     AutoCompleteMode="Suggest"
     SelectionMode="Single"
     DropDownItemTemplate="{StaticResource RoomInterviewerSearchAutoComplete}"
     BorderBrush="#FF25A0DA" BorderThickness="1"
     SelectionChanged="Acb_Interviewer_OnSelectionChanged" />
 
 <DataTemplate x:Key="RoomInterviewerSearchAutoComplete">
    <StackPanel Orientation="Horizontal">
        <TextBlock Text="{Binding}" Style="{StaticResource AutoCompleteStyle}" />
    </StackPanel>
</DataTemplate>

 

The ItemSource is set to a List<string>.

I then try something like this but acb_Interviewer.SelectedItem remains null and only the watermark is visible in the control.

string interviewerName = dbContext.Users.First(u => u.Id == interview.PrimaryUserId).FullName;
acb_Interviewer.SelectedItem = interviewerName;

 

 What am I doing wrong?

1 Answer, 1 is accepted

Sort by
0
Geri
Telerik team
answered on 24 Nov 2015, 06:53 AM
Hi Morgan,

We tried to reproduce the behavior you describe, but with no luck.
Please find attached a sample project we used for testing purposes. It would be of great help if you could modify it so that the described behavior to appear and send it back or send us a runnable sample project of your own. This way, we can be sure we're on the same page and could further investigate.

Looking forward to your reply.

Regards,
Geri
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
AutoCompleteBox
Asked by
IPV
Top achievements
Rank 1
Answers by
Geri
Telerik team
Share this question
or