Element is already the child of another element bug

7 posts, 0 answers
  1. Taher
    Taher avatar
    21 posts
    Member since:
    Jun 2010

    Posted 11 May 2011 Link to this post

    Hi Telerik

    I have this small code
     <Controls:RadTileView x:Name="ContentBorder"   ItemsSource="{Binding Path=Views, ElementName=LocalThis}">
    
                <Controls:RadTileView.ContentTemplate>
                    <DataTemplate>
                        <ContentControl Content="{Binding Path=View}" />
                    </DataTemplate>
                </Controls:RadTileView.ContentTemplate>
     
            </Controls:RadTileView>
    
    The view property contain my visual view, When i run this code every thing work very fine, drag drop also OK but when i try to resize(max any item)
    i get runtime error says "Element already a child of another element", There a note here: When i replace tile view control with 
    it's similar from BlackLight every thing work very fine with all functionality so i guess the problem from TileView control
    please help me
  2. Taher
    Taher avatar
    21 posts
    Member since:
    Jun 2010

    Posted 12 May 2011 Link to this post

    Any reply please
  3. DevCraft banner
  4. Zarko
    Admin
    Zarko avatar
    755 posts

    Posted 12 May 2011 Link to this post

    Hi taher,
    Could you please give us some more code snippets or a sample project that reproduces this issue because I wasn't able to recreate it? I've attached the sample project that I used for testing so you could examine it.

    Kind regards,
    Zarko
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. mitica
    mitica avatar
    7 posts
    Member since:
    May 2011

    Posted 31 May 2011 Link to this post

    Dear Zarko,

    there is a problem with your attached sample application.
    I made the following modifications in order to use the UI Virtualization feature of TileView control:
    - added 120 items
    public MainPage()
            {
                InitializeComponent();
     
                this.views = new ObservableCollection<MyTileViewItem>();
     
                for (int i = 0; i < 120; i++)
                {
                    this.Views.Add(new MyTileViewItem() { Header = i.ToString(), View = new MyView() });
                }
            }

    - modified the MainPage.xaml
    <telerik:RadTileView x:Name="ContentBorder"
                                    ItemsSource="{Binding Path=Views, ElementName=LocalThis}"
                                    MaxColumns="4" MaxRows="4"
                                MinimizedItemsPosition="Right" MinimizedColumnWidth="250" MinimizedRowHeight="140"                             
                                RowHeight="225" ColumnWidth="400" ColumnsCount="4"
                                IsAnimationOptimized="True" IsAutoScrollingEnabled="True"
                                telerik:TileViewPanel.IsVirtualized="True">
                    
                   <telerik:RadTileView.ItemTemplate>
                       <DataTemplate>
                           <TextBlock Text="{Binding Path=Header}"></TextBlock>
                       </DataTemplate>
                   </telerik:RadTileView.ItemTemplate>
     
                   <telerik:RadTileView.ContentTemplate>
                       <DataTemplate>
                           <ContentControl Content="{Binding Path=View}" />
                       </DataTemplate>
                   </telerik:RadTileView.ContentTemplate>
               </telerik:RadTileView>

    The problem is the following:
    when running the application the scrollbar appears as expected on the right side, allowing to scroll down to view more items.
    When reaching the bottom and then scrolling back up, the Content from the TileViewItems dissapear.

    An exception is thrown in the browser console:
    Uncaught Error: Unhandled Error in Silverlight Application
    Code: 4004   
    Category: ManagedRuntimeError      
    Message: System.ArgumentException: Value does not fall within the expected range.
     
       at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
     
       at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, DependencyObject doh)
     
       at MS.Internal.XcpImports.SetValue(IManagedPeerBase doh, DependencyProperty property, Object obj)
     
       at System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)
     
       at System.Windows.DependencyObject.SetEffectiveValue(DependencyProperty property, EffectiveValueEntry& newEntry, Object newValue)
     
       at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
     
       at System.Windows.DependencyObject.RefreshExpression(DependencyProperty dp)
     
       at System.Windows.Data.BindingExpression.SendDataToTarget()
     
       at System.Windows.Data.BindingExpression.SourceAcquired()
     
       at System.Windows.Data.BindingExpression.System.Windows.IDataContextChangedListener.OnDataContextChanged(Object sender, DataContextChangedEventArgs e)
     
       at System.Windows.Data.BindingExpression.DataContextChanged(Object sender, DataContextChangedEventArgs e)
     
       at System.Windows.FrameworkElement.OnDataContextChanged(DataContextChangedEventArgs e)
     
       at System.Windows.FrameworkElement.OnTreeParentUpdated(DependencyObject newParent, Boolean bIsNewParentAlive)
     
       at System.Windows.DependencyObject.UpdateTreeParent(IManagedPeer oldParent, IManagedPeer newParent, Boolean bIsNewParentAlive, Boolean keepReferenceToParent)
     
       at MS.Internal.FrameworkCallbacks.ManagedPeerTreeUpdate(IntPtr oldParentElement, IntPtr parentElement, IntPtr childElement, Byte bIsParentAlive, Byte bKeepReferenceToParent, Byte bCanCreateParent)

    Is there a problem with Binding the Content Template of the TileViewItem to UserControls when using Virtualization?

    Thank you.
  6. Zarko
    Admin
    Zarko avatar
    755 posts

    Posted 02 Jun 2011 Link to this post

    Hello mitica,
    Thank you for the bug report. I've logged it into our PITS under the name "TileView with ContentControl/Presenter in its DataTemplate doesn't work with virtualization" and it will be ready for tracking tomorrow the latest. Unfortunately for now I can't give you a good work around, the only thing you can do is turn off the virtualization or remove the ContentControl/presenter from the DataTemplate.
    I've updated your telerik account and if you have more questions feel free to ask. 

    Best wishes,
    Zarko
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Harinath Reddy
    Harinath Reddy avatar
    4 posts
    Member since:
    Nov 2010

    Posted 04 Jun 2011 Link to this post


    We have a similar problem while refreshing the ItemsSource of RadTileView through WorklistItemCollection in ViewModel. Pls advise.

    While loading the RadTileView first time, it binds and get the items from viewmodel properly. The problems occurs while refreshingusing propertychanged event.

    View
    -----------------------------------
     <telerik:RadTileView x:Name="RTVWorkList"
                                             Margin="0,15,0,0"
                                             ItemsSource="{Binding WorklistItemCollection,Mode=TwoWay}"
                                             MaximizeMode="Zero"
                                             ItemTemplate="{StaticResource TeamTemplate}"
                                             MaxColumns="1"
                                             ItemContainerStyle="{StaticResource RadTileViewItemStyle}">

    <DataTemplate x:Key="TeamTemplate">
                    <StackPanel Orientation="Horizontal"
                                x:Name="spWorkListItem"
                                HorizontalAlignment="Stretch"
                                Background="Transparent">
                        <TextBlock Text="{Binding item.iQueueNo}"
                                   Width="20"
                                   Margin="5"
                                   VerticalAlignment="Center" />
                        
                        <TextBlock Text="{Binding person.sGivenNamePT}"
                                   Width="100"
                                   VerticalAlignment="Center" />
                    </StackPanel>
                </DataTemplate>


    ViewModel 
    -----------------------------
    List<WorkListItem> _worklistItemCollection;
            public List<WorkListItem> WorklistItemCollection
            {
                get
                {
                    return _worklistItemCollection;
                }


                set
                {
                    _worklistItemCollection = null;
                    _worklistItemCollection = value;


                    RaisePropertyChanged("WorklistItemCollection");
                }


            }
  8. Zarko
    Admin
    Zarko avatar
    755 posts

    Posted 08 Jun 2011 Link to this post

    Hello Harinath Reddy,
    Could you please be more specific on what exactly is not working correct because when I tried it I couldn't find any problems? I've attached the sample project that I used for testing so could you please examine it and see if it helps you? Also one advice: when you bind to a collection you should use the ObservableCollection because the List doesn't implement the INotifyCollectionChanged interface.
    If you have more questions please feel free to ask.


    Best wishes,
    Zarko
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top
DevCraft banner