RadListBox Visibility.Collapsed

3 posts, 1 answers
  1. Robbe Morris
    Robbe Morris avatar
    25 posts
    Member since:
    Apr 2004

    Posted 06 May 2012 Link to this post

    Thoughts on what I'm doing wrong here?  If I collapse a ListBoxItem, why does the RadListBox control on partially collapse it?  It still has a height of a couple of pixels when the bound property for visiblity is set to Visibility.Collapsed.

    <telerik:RadListBox Name="MainListControl" Grid.Row="3" 
                            ItemsSource="{Binding Path=HumanResources,Mode=TwoWay}" >
                        <StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
                        <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch"  Visibility="{Binding Path=IsVisible, Mode=TwoWay,Converter={StaticResource localVisibilityConverter}}" >
                                <RowDefinition />
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*" />
                            <StackPanel Name="ButtonPanel" Grid.Column="0" Orientation="Horizontal" HorizontalAlignment="Left" Margin="3,3,3,3">
                                <telerik:RadButton x:Name="EditButton" Margin="3,3,3,3" Click="Edit_Click" Tag="{Binding Path=HumanResourceID}"  Content="{Binding Edit, Source={StaticResource GeneralStrings}}"   />
                            <TextBlock Grid.Column="1" x:Name="expanderCaption" HorizontalAlignment="Stretch" VerticalAlignment="Center"  Text="{Binding Path=Description}" Margin="3,3,3,3"  />
  2. Answer
    Dani avatar
    848 posts

    Posted 09 May 2012 Link to this post

    Hi Robbe,

    What you are doing is actually setting Visibility to the Content of the RadListBoxItem instead of the item itself. Collapsed visibility in the DataTemplate will only hide content of the listbox item, but the rest of the control template, like borders for mouse over and selected states, will remain visible. And this is just what happens in your scenario. That is why the item you expect to be hidden, shows thin borders only.

    The native MS ListBox control behaves in the same way. Only, no Borders remain visible because the visual states of the item do not use borders at all. So there is no visual representation of the item. But it is still there and only its Content is hidden.

    It is best if you simply add or remove items to the collection. But If your scenario does not allow that, I suggest you consider using a StyleSelector to provide a separate style for items you wish to be hidden. In that style, all borders and border thicknesses should be removed. You can leave the ContentPresenter only.

    I hope this information will be helpful.

    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  3. Robbe Morris
    Robbe Morris avatar
    25 posts
    Member since:
    Apr 2004

    Posted 09 May 2012 Link to this post

    I had a feeling it was something like this.  Thanks for confirming it for me.  For anyone who comes along and finds this.  The easiest solution in my case was to implement binding the RadListBox to a CollectionViewSource and binding the listbox to its .View property.  I then used the Filter callback to filter on my .IsVisible property.






Back to Top