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

Exception when setting ItemContainerStyle

1 Answer 37 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Brendan
Top achievements
Rank 1
Brendan asked on 14 Aug 2012, 03:30 AM
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?

1 Answer, 1 is accepted

Sort by
0
Brendan
Top achievements
Rank 1
answered on 14 Aug 2012, 03:51 AM
Sorry I just realised I am using ListBoxItem instead of RadListBoxItem for the TargetType. Works fine
Tags
ListBox
Asked by
Brendan
Top achievements
Rank 1
Answers by
Brendan
Top achievements
Rank 1
Share this question
or