Exception when setting ItemContainerStyle

2 posts, 0 answers
  1. Brendan
    Brendan avatar
    34 posts
    Member since:
    Oct 2010

    Posted 13 Aug 2012 Link to this post

    There seems to be a bug where setting ItemContainerStyle on the RadListBox throws a XamlParseException. Below is code to replicate the problem:

    xaml:
    <Grid>
        <Grid.Resources>
            <Style x:Key="ItemStyle" TargetType="ListBoxItem" />
        </Grid.Resources>
     
        <StackPanel Orientation="Horizontal">
            <StackPanel Width="100" Margin="5">
                <telerik:RadButton Content="Add" Click="AddToList1" />
                <telerik:RadListBox x:Name="List1" Height="100" />
            </StackPanel>
     
            <StackPanel Width="100" Margin="5">
            <telerik:RadButton Content="Add" Click="AddToList2" />
                <telerik:RadListBox x:Name="List2" Height="100" ItemContainerStyle="{StaticResource ItemStyle}" />
            </StackPanel>
        </StackPanel>
    </Grid>

    Code:
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }
     
        private void AddToList1(object sender, RoutedEventArgs e)
        {
            List1.Items.Add("Item");
        }
     
        private void AddToList2(object sender, RoutedEventArgs e)
        {
            List2.Items.Add("Item");
        }
    }

    Is it possible to get a hotfix for this?
  2. Brendan
    Brendan avatar
    34 posts
    Member since:
    Oct 2010

    Posted 13 Aug 2012 Link to this post

    Sorry I just realised I am using ListBoxItem instead of RadListBoxItem for the TargetType. Works fine
  3. DevCraft banner
Back to Top