This question is locked. New answers and comments are not allowed.
I am getting a "Layout Cycle Detected" error when using many TextClipper controls in my application. I have managed to isolate the issue in a small silverlight project (see below). You can see the problem by adding around 250 items to the ItemsControl and resizing the window.
| <UserControl x:Class="SilverlightApplication25.MainControl" | |
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
| xmlns:TelerikControls_Primitives="clr-namespace:Telerik.Windows.Controls.Primitives;assembly=Telerik.Windows.Controls" | |
| > | |
| <Grid> | |
| <Grid.RowDefinitions> | |
| <RowDefinition Height="50" /> | |
| <RowDefinition Height="1*" /> | |
| </Grid.RowDefinitions> | |
| <Button x:Name="btn" Content="0 items" Click="Button_Click" Grid.Row="0" /> | |
| <ScrollViewer Grid.Row="1"> | |
| <ItemsControl x:Name="itemscontrol" ItemsSource="{Binding}"> | |
| <ItemsControl.ItemTemplate> | |
| <DataTemplate> | |
| <TelerikControls_Primitives:TextClipper Content="{Binding Path=MyProperty}" Foreground="#FF002D62" FontFamily="Portable User Interface" FontWeight="Normal" FontSize="20" IsTabStop="False" ToolTipService.ToolTip="{Binding Path=MyProperty}" /> | |
| </DataTemplate> | |
| </ItemsControl.ItemTemplate> | |
| </ItemsControl> | |
| </ScrollViewer> | |
| </Grid> | |
| </UserControl> |
| using System.Windows; | |
| using System.Windows.Controls; | |
| namespace SilverlightApplication25 | |
| { | |
| public partial class MainControl : UserControl | |
| { | |
| public System.Collections.ObjectModel.ObservableCollection<MyObject> TheList = new System.Collections.ObjectModel.ObservableCollection<MyObject>(); | |
| public MainControl() | |
| { | |
| InitializeComponent(); | |
| this.itemscontrol.DataContext = TheList; | |
| } | |
| private void Button_Click(object sender, RoutedEventArgs e) | |
| { | |
| for (int i = 1; i <= 50; i++) | |
| TheList.Add(new MyObject() { MyProperty = System.Guid.NewGuid().ToString() }); | |
| this.btn.Content = string.Format("{0} items", TheList.Count.ToString()); | |
| } | |
| public class MyObject | |
| { | |
| public string MyProperty { get; set; } | |
| } | |
| } | |
| } |