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

ItemContainerStyleSelector not working

2 Answers 103 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Lars-Erik
Top achievements
Rank 1
Lars-Erik asked on 19 Mar 2012, 12:52 PM
Hi! 
I'm having trouble getting the ItemContainerStyleSelector feature on the RadListBox working. Has this feature been fully implemented? I'm using version 2012.1.306.1050 of the telerik library.

Source code below...

<telerik:RadListBox x:Name="structureListBox" ItemContainerStyleSelector="{StaticResource StructureListBoxItemContainerStyleSelector}" ItemsSource="{Binding Path=StructureNodes}" ItemTemplate="{StaticResource StructureListItemTemplate}" Style="{StaticResource StructureListBoxStyle}" />                 

<local:StructureNodeItemContainerStyleSelector x:Key="StructureListBoxItemContainerStyleSelector"
                                                            ControllerStyle="{StaticResource StructureListBoxControllerNodeStyle}"
                                                           FolderStyle="{StaticResource StructureListBoxFolderNodeStyle}"/>

   public class StructureNodeItemContainerStyleSelector : StyleSelector
    {
        public Style FolderStyle { get; set; }
        public Style ControllerStyle { get; set; }


        public override Style SelectStyle(object item, DependencyObject container)
        {
            if (item is FolderNode)
                return FolderStyle;
            return ControllerStyle;
        }
    }

    <Style x:Key="StructureListBoxControllerNodeStyle" TargetType="telerik:RadListBoxItem">
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="VerticalContentAlignment" Value="Top"/>      
        <Setter Property="Background" Value="#FFFFFFFF"/>
        <Setter Property="BorderBrush" Value="#FF878686"/>
        <Setter Property="Margin" Value="0"/>      
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Padding" Value="5 0 5 0"/>
        <Setter Property="TabNavigation" Value="Local"/>
    </Style>

 <Style x:Key="StructureListBoxFolderNodeStyle" TargetType="telerik:RadListBoxItem">
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="VerticalContentAlignment" Value="Top"/>
        <Setter Property="Background">
            <Setter.Value>
                <LinearGradientBrush EndPoint="0.5,1.021" StartPoint="0.5,0.027">
                    <GradientStop Color="White" Offset="0"/>
                    <GradientStop Color="#FFC9C9CC" Offset="1"/>
                </LinearGradientBrush>
            </Setter.Value>
        </Setter>
        <Setter Property="BorderBrush" Value="#FF999999"/>
        <Setter Property="Margin" Value="0"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Padding" Value="5 0 5 0"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="TabNavigation" Value="Local"/>
    </Style>

2 Answers, 1 is accepted

Sort by
0
Andy
Top achievements
Rank 1
answered on 20 Mar 2012, 11:09 PM
Same here. It just doesn't work for me. I just restructured all my stuff for this too :(
0
George
Telerik team
answered on 22 Mar 2012, 10:49 AM
Hello,

 
We can confirm that the RadListBox control doesn't support this functionality as CTP, but it will be implemented for the final version (Q2 release). 

All the best,
George
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
ListBox
Asked by
Lars-Erik
Top achievements
Rank 1
Answers by
Andy
Top achievements
Rank 1
George
Telerik team
Share this question
or