Windows8Touch StyleSelector for ListBox not working

3 posts, 0 answers
  1. Muhammad Ummar
    Muhammad Ummar avatar
    26 posts
    Member since:
    Jul 2012

    Posted 30 May 2013 Link to this post

    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. Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 04 Jun 2013 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Muhammad Ummar
    Muhammad Ummar avatar
    26 posts
    Member since:
    Jul 2012

    Posted 04 Jun 2013 Link to this post

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