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

Conditional Hiding of RadComboBoxItem

2 Answers 220 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Juliana
Top achievements
Rank 1
Juliana asked on 21 Dec 2011, 02:11 PM
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 Answers, 1 is accepted

Sort by
0
Juliana
Top achievements
Rank 1
answered on 17 Jan 2012, 02:11 PM
any suggestion?
0
Gaga
Top achievements
Rank 2
answered on 23 Jan 2012, 05:06 PM
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
Tags
ComboBox
Asked by
Juliana
Top achievements
Rank 1
Answers by
Juliana
Top achievements
Rank 1
Gaga
Top achievements
Rank 2
Share this question
or