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

Element is already the child of another element bug

6 Answers 216 Views
TileView
This is a migrated thread and some comments may be shown as answers.
Taher
Top achievements
Rank 1
Taher asked on 11 May 2011, 11:17 AM
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

6 Answers, 1 is accepted

Sort by
0
Taher
Top achievements
Rank 1
answered on 12 May 2011, 01:06 PM
Any reply please
0
Zarko
Telerik team
answered on 12 May 2011, 01:45 PM
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
0
mitica
Top achievements
Rank 1
answered on 31 May 2011, 01:08 PM
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.
0
Zarko
Telerik team
answered on 02 Jun 2011, 09:11 AM
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
0
Harinath Reddy
Top achievements
Rank 1
answered on 04 Jun 2011, 11:16 AM

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");
            }


        }
0
Zarko
Telerik team
answered on 08 Jun 2011, 02:09 PM
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
Tags
TileView
Asked by
Taher
Top achievements
Rank 1
Answers by
Taher
Top achievements
Rank 1
Zarko
Telerik team
mitica
Top achievements
Rank 1
Harinath Reddy
Top achievements
Rank 1
Share this question
or