ItemTemplate on RadRibbonComboBox not showing DisplayMemberPath

4 posts, 0 answers
  1. Nemanja
    Nemanja avatar
    27 posts
    Member since:
    Mar 2011

    Posted 19 Jan 2012 Link to this post

    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.

  2. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 20 Jan 2012 Link to this post

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

  3. UI for WPF is Visual Studio 2017 Ready
  4. Nemanja
    Nemanja avatar
    27 posts
    Member since:
    Mar 2011

    Posted 25 Jan 2012 Link to this post

    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.
  5. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 30 Jan 2012 Link to this post

    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 >>
Back to Top