Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > ComboBox > ItemTemplate on RadRibbonComboBox not showing DisplayMemberPath

Not answered ItemTemplate on RadRibbonComboBox not showing DisplayMemberPath

Feed from this thread
  • Nemanja avatar

    Posted on Jan 19, 2012 (permalink)

    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.

    Reply

  • Valeri Hristov Valeri Hristov admin's avatar

    Posted on Jan 20, 2012 (permalink)

    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 >>

    Reply

  • Nemanja avatar

    Posted on Jan 25, 2012 (permalink)

    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.

    Reply

  • Konstantina Konstantina admin's avatar

    Posted on Jan 30, 2012 (permalink)

    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 >>

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > ComboBox > ItemTemplate on RadRibbonComboBox not showing DisplayMemberPath
Related resources for "ItemTemplate on RadRibbonComboBox not showing DisplayMemberPath"

WPF ComboBox Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]