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

ItemTemplate on RadRibbonComboBox not showing DisplayMemberPath

3 Answers 246 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Nemanja
Top achievements
Rank 1
Nemanja asked on 19 Jan 2012, 12:14 PM
Hi,

I'm having a problem re-templating combo box items on the RadRibbonComboBox. The item template works fine only for items in the drop down, but not for the selected item that shows when the como is closed. I bind the ItemsSource to a collection of custom entities, and was setting the DisplayMemberPath to one of their properties - MemberDisplay - but I now need to do extra formatting on the display so as to change the background colour of certain items based on values in the entity.

As i said, it works for the items in the dropdown, but not for the selection box items. Here is the xaml:

<rad:RadRibbonComboBox
    Width="95"
    Margin="0 5 0 0"
    IsEditable="True"
    IsReadOnly="True"
    ItemsSource="{Binding TimeFilterFromMonitorCombo.Items}"
    SelectedItem="{Binding TimeFilterFromMonitorCombo.SelectedItem}"
    IsSynchronizedWithCurrentItem="True">
    <rad:RadRibbonComboBox.ItemsPanel>
        <ItemsPanelTemplate>
            <VirtualizingStackPanel />
        </ItemsPanelTemplate>
    </rad:RadRibbonComboBox.ItemsPanel>
    <rad:RadRibbonComboBox.ItemTemplate>
        <DataTemplate>                                       
            <StackPanel Orientation="Horizontal">
                <TextBlock Background="{Binding ItemBackground}" Text="{Binding MemberDisplay}" HorizontalAlignment="Stretch" />                                       
            </StackPanel>
        </DataTemplate>
    </rad:RadRibbonComboBox.ItemTemplate>                               
</rad:RadRibbonComboBox>


That seems right to me, and when i use this kind of concept for other combos it works ok. Is this something particular to RibbonComboBox controls? I've attached images of how it looks in the application.

3 Answers, 1 is accepted

Sort by
0
Valeri Hristov
Telerik team
answered on 20 Jan 2012, 10:21 AM
Hello,

You didn't specified the property name that should be displayed in the TextBox. This is done with the telerik:TextSearch.TextPath attached property. Please, check the following help article for more information:
http://www.telerik.com/help/wpf/radcombobox-features-autocomplete.html#using_textsearch_textpath

Kind regards,
Valeri Hristov
the Telerik team

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

0
Nemanja
Top achievements
Rank 1
answered on 25 Jan 2012, 03:16 PM
Thanks for the help, that solved the problem somewhat. The issue i'm having now is that the item background is only set in the drop down items and doesn't show in the selected item once the combo is closed.

My understanding of the documentation was that if you set the itemtemplate, it will apply to the selected item as well unless otherwise specified. I tried to change the selectionboxtemplate as well, but it still didn't make a difference.
0
Konstantina
Telerik team
answered on 30 Jan 2012, 06:12 PM
Hi,

The selected item's background does not depend on the SelectionBoxTemplate. In order to change the background of the selected item you need to change the style of the ComboBox. You could extract its style very easy with Expression Blend. Just drop a RadComboBox control on the design surface, right-click it and choose from the menu Edit Template->Edit a Copy. The Blend will generate all the needed styles and template. There are 2 main templates: EditableTemplate and NonEditableTemplate.
If the ComboBox is in non-editable mode, it is represented by a ButtonChrome element, which template should be changed in order to change the background. More information how to edit this element you could find in this KB article.
If you ComboBox is in editable mode, then the EditableTemplate will be applied and all you need to set/bind is the Background property of the RadComboBox.

Hope this helps.

Regards,
Konstantina
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Tags
ComboBox
Asked by
Nemanja
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Nemanja
Top achievements
Rank 1
Konstantina
Telerik team
Share this question
or