I am using ItemTemplate and SelectionBoxTemplate in RadCombobox. ItemTemplate is showing as expected
but the selectionboxitem is showing EntityName:EntityKey format (UserEntity:1020 like this.)
This is the markup i am using:
<
telerik:RadComboBox
VerticalAlignment
=
"Center"
IsEditable
=
"True"
IsReadOnly
=
"True"
TextSearchMode
=
"StartsWith"
IsFilteringEnabled
=
"True"
ItemsSource
=
"{Binding Path=NewPreference.LstSalesPerson}"
SelectedValue
=
"{Binding Path=NewPreference.ReferedTo, Mode=TwoWay}"
SelectedValuePath
=
"Username"
>
<
telerik:RadComboBox.SelectionBoxTemplate
>
<
DataTemplate
>
<
Grid
>
<
TextBlock
Text
=
"{Binding Path=Name}"
VerticalAlignment
=
"Center"
FontWeight
=
"Bold"
/>
</
Grid
>
</
DataTemplate
>
</
telerik:RadComboBox.SelectionBoxTemplate
>
<
telerik:RadComboBox.ItemTemplate
>
<
DataTemplate
>
<
Grid
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"27"
/>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"Auto"
/>
</
Grid.RowDefinitions
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
Width
=
"100"
/>
<
ColumnDefinition
MinWidth
=
"100"
Width
=
"Auto"
/>
</
Grid.ColumnDefinitions
>
<
TextBlock
Text
=
"{Binding Path=Name}"
Grid.Row
=
"0"
Grid.Column
=
"0"
Grid.ColumnSpan
=
"2"
VerticalAlignment
=
"Top"
HorizontalAlignment
=
"Stretch"
FontWeight
=
"Bold"
Margin
=
"0,2"
/>
<
TextBlock
Text
=
"{Binding Path=PhoneNo, Converter={StaticResource zeroConverter}}"
Grid.Row
=
"1"
Grid.Column
=
"0"
VerticalAlignment
=
"Center"
HorizontalAlignment
=
"Stretch"
Margin
=
"0,3"
/>
<
TextBlock
Text
=
"{Binding Path=MobileNo, Converter={StaticResource zeroConverter}}"
Grid.Row
=
"1"
Grid.Column
=
"1"
VerticalAlignment
=
"Center"
HorizontalAlignment
=
"Stretch"
Margin
=
"0,3"
/>
<
TextBlock
Text
=
"{Binding Path=Email, Converter={StaticResource zeroConverter}}"
Grid.Row
=
"2"
Grid.Column
=
"0"
Grid.ColumnSpan
=
"2"
VerticalAlignment
=
"Center"
HorizontalAlignment
=
"Stretch"
Margin
=
"0,3"
/>
<
TextBlock
Text
=
"Last Assigned"
Grid.Row
=
"3"
Grid.Column
=
"0"
VerticalAlignment
=
"Center"
HorizontalAlignment
=
"Stretch"
Margin
=
"0,3"
/>
<
TextBlock
Text
=
"{Binding Path=LastActivity, StringFormat='dd-MMM-yyyy HH:mm'}"
Grid.Row
=
"3"
Grid.Column
=
"1"
VerticalAlignment
=
"Center"
HorizontalAlignment
=
"Stretch"
Margin
=
"0,3"
/>
</
Grid
>
</
DataTemplate
>
</
telerik:RadComboBox.ItemTemplate
>
</
telerik:RadComboBox
>
13 Answers, 1 is accepted
The SelectionBoxTemplate is applied only to an non-editable ComboBox. The
SelectedValuePath
and SelectedValue
properties should be enough to display the proper value in the TextBox of the ComboBox. You can read more about them in this help article.Please let us know if you have further questions.
Greetings,
Konstantina
the Telerik team
How about if you want to display more than one field in the selected item box? For example, i can do the following in an item template:
<
telerikInput:RadComboBox.ItemTemplate
>
<
DataTemplate
>
<
StackPanel
Orientation
=
"Horizontal"
>
<
TextBlock
Text
=
"{Binding Name, Mode=OneWay}"
/>
<
TextBlock
Text
=
" ("
/>
<
TextBlock
Text
=
"{Binding CompanyCode, Mode=OneWay}"
/>
<
TextBlock
Text
=
")"
/>
</
StackPanel
>
</
DataTemplate
>
</
telerikInput:RadComboBox.ItemTemplate
>
How do I get the same formatting in the selection box?
Please check out this help article - it explains how to use SelectionBoxTemplate. Try it and if you have any additional issues, write to us again.
Best wishes,
Yana
the Telerik team
It would have been really helpful if this was in the online help - save me and others heaps of time.
You are right, we will include it in the article. Thank you for the feedback.
Kind regards,
Yana
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
<telerik:RadComboBox Name="ddlDocument"
ItemsSource="{Binding Path=Filing.Documents}"
IsReadOnly="True"
Width="145"
MinHeight="20"
IsEditable="True"
TextInputStart="ddlDocument_TextInputStart">
<telerik:RadComboBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Width="Auto" Text="{Binding Path=Caption}" VerticalAlignment="Center" />
<TextBlock Text="(" />
<TextBlock Text="{Binding Path= DocketCode.Code}" HorizontalAlignment="Right" VerticalAlignment="Center" />
<TextBlock Text=")" />
</StackPanel>
</StackPanel>
</DataTemplate>
</telerik:RadComboBox.ItemTemplate>
As i said i have also tried the selection box template i want use the autocomplete feature for either the "Code" or the "Caption" from the above code. can u please direct me to any similar sample you have or you can feel free to correct/add code to the above sample.....
You should also set SelectedValuePath and telerik:TextSearch.TextPath properties to the field that should be shown in the combobox input:
<
telerik:RadComboBox
Name
=
"ddlDocument"
SelectedValuePath
=
"Caption"
telerik:TextSearch.TextPath
=
"Caption"
... >
All the best,
Yana
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
This is my combo box,
<
telerik:RadComboBox
x:Name
=
"cmbTags"
ItemsSource
=
"{Binding Tags_CustmFldDetails.TagsList,Mode=TwoWay}"
SelectedIndex
=
"0"
IsReadOnly
=
"False"
SelectedItem
=
"{Binding Tags_CustmFldDetails.SelectedTag, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
HorizontalAlignment
=
"Left"
Width
=
"188"
VerticalAlignment
=
"Top"
Margin
=
"115,42,0,0"
Height
=
"23"
>
<
telerik:RadComboBox.ItemTemplate
>
<
DataTemplate
>
<
TextBox
Text
=
"{Binding TagName,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
HorizontalAlignment
=
"Left"
Width
=
"100"
/>
</
DataTemplate
>
</
telerik:RadComboBox.ItemTemplate
>
</
telerik:RadComboBox
>
I have Observable collection call "TagsList" and property for selected item, all bindings work fine.
When i select 1st item in drop down it get show in combo box, Problem is, if expand drop down and edit same item and select it again those changes will not be display on combo box ?
Can you share how exactly do you edit the item - in the code? However in order to notify the UI when modifying properties in the code, you would need to implement INotifyPropertyChanged interface in your custom object class as shown in the following article:
http://msdn.microsoft.com/en-us/library/vstudio/ms229614%28v=vs.100%29.aspx
Hope this helps.
Regards,
Kalin
Telerik
Hello,
"The SelectionBoxTemplate is applied only to an non-editable ComboBox. "
4 years later, and still not included it in the help article !!!!!
I lost one hour finding out what was wrong ...
Arnaud.
Ok now i've in mind that: The SelectionBoxTemplate is applied only to an non-editable ComboBox, could yould please help me changing the FontStyle of the edition/selection element without using this feature ?
Best regards,
Arnaud.
As said here: The SelectionBoxTemplate is applied only to an non-editable ComboBox. But then how could we change, for example, the FontSyle of the edition/selection element with IsEditable="True" ?
Best Regards,
Arnaud.
Thanks for the feedback and I apologize for the inconvenience - we will include it as soon possible. As for your question - you can use the TextBoxStyle property in order to apply a custom TextBox style for the input part of the control.
Hope this helps.
Regards,
Kalin
Telerik