Items.Item(i) Visibility ?

4 posts, 0 answers
  1. Davor
    Davor avatar
    3 posts
    Member since:
    Dec 2010

    Posted 22 Mar 2011 Link to this post

    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!
  2. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 22 Mar 2011 Link to this post

    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
  3. DevCraft banner
  4. Davor
    Davor avatar
    3 posts
    Member since:
    Dec 2010

    Posted 22 Mar 2011 Link to this post

    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!
  5. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 22 Mar 2011 Link to this post

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