Conditional Hiding of RadComboBoxItem

3 posts, 0 answers
  1. Juliana
    Juliana avatar
    71 posts
    Member since:
    Feb 2008

    Posted 21 Dec 2011 Link to this post

    Hi,
    I have a collection of items. It is bound to two different comboboxes. Is it possible to hide some items in one of the comboboxes?
    I tried smth like
    <telerik:RadComboBox>
    <telerik:RadComboBox.ItemContainerStyle>
                        <Style TargetType="telerik:RadComboBoxItem">
                            <Setter Property="Visibility" Value="{Binding SomeBooleanProperty, Converter={StaticResource BooleanToVisibilityConverter}}"/>
                        </Style>
                    </telerik:RadComboBox.ItemContainerStyle>
    </telerik:RadComboBox>

    But it didn't work out.
    Any directions?

    Best Regards,
    Juliana
  2. Juliana
    Juliana avatar
    71 posts
    Member since:
    Feb 2008

    Posted 17 Jan 2012 Link to this post

    any suggestion?
  3. DevCraft banner
  4. Gaga
    Gaga avatar
    4 posts
    Member since:
    Oct 2010

    Posted 23 Jan 2012 Link to this post

    Hello Juliana,

    I had similar problem a couple of days ago. This post helped me solve it: How to enable/disable specific items in RadComboBox.

    Long story short. Just make your custom ItemTemplate for RadComboBox:
    <telerik:RadComboBox.ItemTemplate>
        <DataTemplate>
            <telerik:ContainerBinding.ContainerBindings>
                <telerik:ContainerBindingCollection>
                    <telerik:ContainerBinding PropertyName="Visibility" Binding="{Binding Enabled, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}" />
                </telerik:ContainerBindingCollection>
            </telerik:ContainerBinding.ContainerBindings>
            <TextBlock Text="{Binding DisplayProperty, Mode=OneWay}" />
        </DataTemplate>
    </telerik:RadComboBox.ItemTemplate>

    And don't forget to set for proper display RadComboBox settings to (it's replacement for 'DisplayMemeberPath' which does not work with custom item templates):
    telerik:TextSearch.TextPath="DisplayProperty"

    I hope this solution will help you too. :)

    Best Regards,
    Dragana
Back to Top