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

Windows8Touch StyleSelector for ListBox not working

2 Answers 68 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Muhammad Ummar
Top achievements
Rank 1
Muhammad Ummar asked on 30 May 2013, 11:08 AM
Hello,

I am facing issue with RadListBox control styling issue when using Windows8Touch theme. Following is the description

1- I want to use different styles for each RadListBoxItem so I am using StyleSelector , It is working fine for all other themes, but as soon as I switch my application to Windows8Touch,  StylesSelector stopped working. On some drilling down I came to know that in Windows8Touch "StyleSelector.SelectStyle" is not being called.

2- Following is the code for StyleSelector

public class LstStyleSelector:StyleSelector
    {
        
public Style Red { get; set; }
        
public Style Blue { get; set; }
        
public override Style SelectStyle(object item, DependencyObject container)
        {
            
if (item != null)
            {
                
if (((KeyValuePair<int, string>)item).Key % 2 == 0)
                    
return Red;
                
else
                    return Blue;
            }
            
else
                return Red;
        }
    }

3- Following is the XAML

<Grid>
        <Grid.Resources>
            <Style x:Key="reditem" TargetType="{x:Type telerik:RadListBoxItem}">
                <Setter Property="Background" Value="Red"/>
            </Style>
           
            <Style x:Key="bluitem" TargetType="{x:Type telerik:RadListBoxItem}">
                <Setter Property="Background" Value="Blue"/>
            </Style>
            <local:LstStyleSelector x:Key="itemContainerStyle" Blue="{StaticResource bluitem}" Red="{StaticResource reditem}"/>
           
        </Grid.Resources>
        <telerik:RadListBox x:Name="lstbx" VerticalAlignment="Center" DisplayMemberPath="Value" ItemContainerStyleSelector="{StaticResource itemContainerStyle}"/>
    </Grid>

4- Here I am setting theme in App.xaml.cs

private void Application_Startup(object sender, StartupEventArgs e)
{
    
//StyleManager.ApplicationTheme = new Windows8TouchTheme(); //StyleSelector not working.
    StyleManager.ApplicationTheme = new Office_BlackTheme(); //StyleSelector working fine!
}

Please help me out on this issue. I am using Q1 2013.

Regards.

2 Answers, 1 is accepted

Sort by
0
Kalin
Telerik team
answered on 04 Jun 2013, 08:20 AM
Hello Muhammad,

Thank you for reporting the issue, we successfully reproduced it and it has been logged in our internal backlog. We will do our best to fix for some of the next internal builds.

Regards,
Kalin
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Muhammad Ummar
Top achievements
Rank 1
answered on 04 Jun 2013, 09:24 AM
Thanks Kalin for updating me on issue status. I will appreciate if you can update this thread when the issue is fixed.

Regards
Muhammad Ummar
Tags
ListBox
Asked by
Muhammad Ummar
Top achievements
Rank 1
Answers by
Kalin
Telerik team
Muhammad Ummar
Top achievements
Rank 1
Share this question
or