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

GridViewColumn.Footer Causes Exception on Theme Change

1 Answer 50 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 30 May 2012, 06:56 PM
If I add a Column Header or Footer to a GridViewColumn an InvaidOperationException is thrown with a message of "Specified element is already the logical child of another element. Disconnect it first." when I attempt to change the Theme. If I comment out the footer, there is no exception and the theme changes as expected.

Below is the xaml for the RadGridView and following that is the exception details.

<telerik:RadGridView AutoGenerateColumns="False"
                     Width="498"
                     ShowGroupPanel="False"
                     Margin="0,5,0,0"
                     Height="200"
                     ItemsSource=" "
                     ShowColumnFooters="True"
                     telerik:StyleManager.Theme="{Binding TelerikTheme}">
    <telerik:RadGridView.Columns>
        <telerik:GridViewColumn Header="Period"
                                Width="150">
            <telerik:GridViewColumn.CellTemplate>
                <DataTemplate>
                    <TextBlock Text="Some Data" />
                </DataTemplate>
            </telerik:GridViewColumn.CellTemplate>
            <telerik:GridViewColumn.Footer>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="Period Range"
                               FontWeight="Bold" />
                </StackPanel>
            </telerik:GridViewColumn.Footer>
        </telerik:GridViewColumn>
    </telerik:RadGridView.Columns>
</telerik:RadGridView>

System.InvalidOperationException was unhandled
  Message=Specified element is already the logical child of another element. Disconnect it first.
  Source=PresentationFramework
  StackTrace:
       at System.Windows.FrameworkElement.ChangeLogicalParent(DependencyObject newParent)
       at System.Windows.FrameworkElement.AddLogicalChild(Object child)
       at System.Windows.Controls.ContentControl.OnContentChanged(Object oldContent, Object newContent)
       at System.Windows.Controls.ContentControl.OnContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
       at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
       at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
       at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
       at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
       at Telerik.Windows.Controls.GridView.GridViewFooterRow.PrepareCellProperties(GridViewFooterCell cell, GridViewColumn column) in c:\TB\105\WPF_Scrum\Current_HotFix\Sources\Controls\GridView\GridView\GridView\Rows\GridViewFooterRow.cs:line 277
       at Telerik.Windows.Controls.GridView.GridViewFooterRow.PrepareCell(GridViewCellBase cellBase, GridViewColumn column) in c:\TB\105\WPF_Scrum\Current_HotFix\Sources\Controls\GridView\GridView\GridView\Rows\GridViewFooterRow.cs:line 220
       at Telerik.Windows.Controls.GridView.GridViewCellsPanel.PrepareCell(GridViewCellBase cell, GridViewColumn column) in c:\TB\105\WPF_Scrum\Current_HotFix\Sources\Controls\GridView\GridView\GridView\Virtualization\GridViewCellsPanel.cs:line 410
       at Telerik.Windows.Controls.GridView.GridViewCellsPanel.GetVirtualizedCell(GridViewColumn column, Boolean createIfNull) in c:\TB\105\WPF_Scrum\Current_HotFix\Sources\Controls\GridView\GridView\GridView\Virtualization\GridViewCellsPanel.Virtualization.cs:line 399
       at Telerik.Windows.Controls.GridView.GridViewCellsPanel.RealizeAndMeasureCells(Int32 startIndex, Int32 predictedLastIndex, Func`2 calculateNextIndex) in c:\TB\105\WPF_Scrum\Current_HotFix\Sources\Controls\GridView\GridView\GridView\Virtualization\GridViewCellsPanel.Virtualization.cs:line 334
       at Telerik.Windows.Controls.GridView.GridViewCellsPanel.UpdateVirtualizedCells() in c:\TB\105\WPF_Scrum\Current_HotFix\Sources\Controls\GridView\GridView\GridView\Virtualization\GridViewCellsPanel.Virtualization.cs:line 269
       at Telerik.Windows.Controls.GridView.GridViewCellsPanel.MeasureOverride(Size availableSize) in c:\TB\105\WPF_Scrum\Current_HotFix\Sources\Controls\GridView\GridView\GridView\Virtualization\GridViewCellsPanel.cs:line 306
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
       at System.Windows.Controls.ItemsPresenter.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Control.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
       at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
       at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Border.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Control.MeasureOverride(Size constraint)
       at Telerik.Windows.Controls.GridView.GridViewRowItem.MeasureOverride(Size constraint) in c:\TB\105\WPF_Scrum\Current_HotFix\Sources\Controls\GridView\GridView\GridView\Rows\GridViewRowItem.cs:line 215
       at Telerik.Windows.Controls.GridView.GridViewFooterRow.MeasureOverride(Size availableSize) in c:\TB\105\WPF_Scrum\Current_HotFix\Sources\Controls\GridView\GridView\GridView\Rows\GridViewFooterRow.cs:line 172
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
       at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
       at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.ScrollViewer.MeasureOverride(Size constraint)
       at Telerik.Windows.Controls.GridView.GridViewScrollViewer.MeasureOverride(Size constraint) in c:\TB\105\WPF_Scrum\Current_HotFix\Sources\Controls\GridView\GridView\GridView\ScrollViewer\GridViewScrollViewer.cs:line 179
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
       at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
       at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Border.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Control.MeasureOverride(Size constraint)
       at Telerik.Windows.Controls.GridView.GridViewDataControl.MeasureOverride(Size constraint) in c:\TB\105\WPF_Scrum\Current_HotFix\Sources\Controls\GridView\GridView\GridView\GridViewDataControl.cs:line 6576
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.ContextLayoutManager.UpdateLayout()
       at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
       at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
       at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
       at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.DispatcherOperation.InvokeImpl()
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Windows.Threading.DispatcherOperation.Invoke()
       at System.Windows.Threading.Dispatcher.ProcessQueue()
       at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       at System.Windows.Application.RunInternal(Window window)
       at System.Windows.Application.Run()
       at AM.NET.App.Main() in C:\Dev\Genesis\AM.NET\AM.NET\obj\Debug\App.g.cs:line 50
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

Hopefully there is a work around.

Thank you in advance
Steve

1 Answer, 1 is accepted

Sort by
0
Steve
Top achievements
Rank 1
answered on 30 May 2012, 07:35 PM
I forgot to mention I am using the latest hot fix, 2012.1.0528.
Thanks,
Steve
Tags
GridView
Asked by
Steve
Top achievements
Rank 1
Answers by
Steve
Top achievements
Rank 1
Share this question
or