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

Items.Item(i) Visibility ?

3 Answers 99 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Davor
Top achievements
Rank 1
Davor asked on 22 Mar 2011, 09:34 AM
Hi I have control that has RadComboBox in it, I created:
Public Shared ItemsSourceProperty As DependencyProperty for that control And To populate that ItemsSource I do this:
ItemsSource="{Binding List, Source={StaticResource dpClientColor}}"
Now My Problem is that I want based on some values that are in Item(i) like IsActive to be able to change visibility of Item, not to show up at all, I have tried to remove Item ItemsSource.Remove(ItemsSource.Item(i)) but it say's that This can't be done because it's ReadOnly.
I Tried to do this with Style, then with DataTemplate, every time I got visibility of en Item to bi Collapsed but I could see empty spot in List!

3 Answers, 1 is accepted

Sort by
0
Valeri Hristov
Telerik team
answered on 22 Mar 2011, 11:23 AM
Hi Davor,

Instead of removing the items from the ItemsSource collection of RadComboBox, you should remove them from the List property of the dpClientColor class. This is the recommended way to handle this problem in Silverlight.

Since Silverlight does not support having Binding in Style setters, we have "invented" a workaround that works only for RadControls for Silverlight - ContainerBindings. Using it you could bind the Visibility property of the RadComboBoxItems to a property in your model. Please check the end of the following article:
http://www.telerik.com/help/silverlight/radcombobox-howto-enable-disable-radcombobox-items.html

It demonstrates how to bind the IsEnabled property, but Visibility should be virtually the same, except if you want to bind to a boolean property, you will have to use a converter.

Regards,
Valeri Hristov
the Telerik team
0
Davor
Top achievements
Rank 1
answered on 22 Mar 2011, 11:35 AM
I allready try that, and it's not working, I Cant see Item, but I can see empty spot in List in DropDown.
I can't do this on the List before I hand it to Control, because I need all the items, because if user has Value on his info witch is not Active it should be colored, else it should not be visible!
0
Valeri Hristov
Telerik team
answered on 22 Mar 2011, 04:43 PM
Hello Davor,

Please, find attached a simple application that demonstrates my suggestion. Please, note also that we recently fixed a problem that reset all combobox items visibility when the dropdown was open, so you will have to use the latest version of RadControls for Silverlight - 2011.3.315. I am not sure if this change got into the latest internal builds, but most probably the latest internal build of Q3 2010 should also work as expected.

Best wishes,
Valeri Hristov
the Telerik team
Tags
ComboBox
Asked by
Davor
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Davor
Top achievements
Rank 1
Share this question
or