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

GridViewCustomSerialization exception on loading

10 Answers 291 Views
PersistenceFramework
This is a migrated thread and some comments may be shown as answers.
Gajan
Top achievements
Rank 1
Gajan asked on 09 Mar 2012, 03:43 PM
Hi,

When I try to load a persisted stream into a gridview, I receive the following exception:

[System.ArgumentOutOfRangeException] = {"Index was out of range. Must be
non-negative and less than the size of the collection.\r\nParameter name:
index"}<BR>

Stack trace:

   at
System.ThrowHelper.ThrowArgumentOutOfRangeException()<BR>   at
System.Collections.Generic.List`1.get_Item(Int32 index)<BR>   at
Telerik.Windows.Controls.GridViewColumnCollectionInternal.ColumnFromDisplayIndex(Int32
displayIndex)<BR>   at
Telerik.Windows.Controls.GridView.GridViewCellsPanel.InitializeMeasureData()<BR>  
at Telerik.Windows.Controls.GridView.GridViewCellsPanel.MeasureOverride(Size
availableSize)<BR>   at
System.Windows.FrameworkElement.MeasureCore(Size availableSize)<BR>  
at System.Windows.UIElement.Measure(Size availableSize)<BR>   at
MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size
constraint)<BR>   at
System.Windows.Controls.ItemsPresenter.MeasureOverride(Size
constraint)<BR>   at System.Windows.FrameworkElement.MeasureCore(Size
availableSize)<BR>   at System.Windows.UIElement.Measure(Size
availableSize)<BR>   at
System.Windows.Controls.Grid.MeasureOverride(Size constraint)<BR>   at
System.Windows.FrameworkElement.MeasureCore(Size availableSize)<BR>  
at System.Windows.UIElement.Measure(Size availableSize)<BR>   at
System.Windows.Controls.Control.MeasureOverride(Size constraint)<BR>  
at System.Windows.FrameworkElement.MeasureCore(Size
availableSize)<BR>   at System.Windows.UIElement.Measure(Size
availableSize)<BR>   at System.Windows.Controls.Grid.MeasureCell(Int32
cell, Boolean forceInfinityV)<BR>   at
System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size
referenceSize, Boolean ignoreDesiredSizeU, Boolean
forceInfinityV)<BR>   at
System.Windows.Controls.Grid.MeasureOverride(Size constraint)<BR>   at
System.Windows.FrameworkElement.MeasureCore(Size availableSize)<BR>  
at System.Windows.UIElement.Measure(Size availableSize)<BR>   at
System.Windows.Controls.Control.MeasureOverride(Size constraint)<BR>  
at Telerik.Windows.Controls.GridView.GridViewRowItem.MeasureOverride(Size
constraint)<BR>   at
Telerik.Windows.Controls.GridView.GridViewHeaderRow.MeasureOverride(Size
availableSize)<BR>   at
System.Windows.FrameworkElement.MeasureCore(Size availableSize)<BR>  
at System.Windows.UIElement.Measure(Size availableSize)<BR>   at
System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean
forceInfinityV)<BR>   at
System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size
referenceSize, Boolean ignoreDesiredSizeU, Boolean
forceInfinityV)<BR>   at
System.Windows.Controls.Grid.MeasureOverride(Size constraint)<BR>   at
System.Windows.FrameworkElement.MeasureCore(Size availableSize)<BR>  
at System.Windows.UIElement.Measure(Size availableSize)<BR>   at
System.Windows.Controls.ScrollViewer.MeasureOverride(Size
constraint)<BR>   at
Telerik.Windows.Controls.GridView.GridViewScrollViewer.MeasureOverride(Size
constraint)<BR>   at System.Windows.FrameworkElement.MeasureCore(Size
availableSize)<BR>   at System.Windows.UIElement.Measure(Size
availableSize)<BR>   at System.Windows.Controls.Grid.MeasureCell(Int32
cell, Boolean forceInfinityV)<BR>   at
System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size
referenceSize, Boolean ignoreDesiredSizeU, Boolean
forceInfinityV)<BR>   at
System.Windows.Controls.Grid.MeasureOverride(Size constraint)<BR>   at
System.Windows.FrameworkElement.MeasureCore(Size availableSize)<BR>  
at System.Windows.UIElement.Measure(Size availableSize)<BR>   at
System.Windows.Controls.Border.MeasureOverride(Size constraint)<BR>  
at System.Windows.FrameworkElement.MeasureCore(Size
availableSize)<BR>   at System.Windows.UIElement.Measure(Size
availableSize)<BR>   at
System.Windows.Controls.Control.MeasureOverride(Size constraint)<BR>  
at Telerik.Windows.Controls.GridView.GridViewDataControl.MeasureOverride(Size
constraint)<BR>   at System.Windows.FrameworkElement.MeasureCore(Size
availableSize)<BR>   at System.Windows.UIElement.Measure(Size
availableSize)<BR>   at System.Windows.Controls.Grid.MeasureCell(Int32
cell, Boolean forceInfinityV)<BR>   at
System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size
referenceSize, Boolean ignoreDesiredSizeU, Boolean
forceInfinityV)<BR>   at
System.Windows.Controls.Grid.MeasureOverride(Size constraint)<BR>   at
System.Windows.FrameworkElement.MeasureCore(Size availableSize)<BR>  
at System.Windows.UIElement.Measure(Size availableSize)<BR>   at
System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean
forceInfinityV)<BR>   at
System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size
referenceSize, Boolean ignoreDesiredSizeU, Boolean
forceInfinityV)<BR>   at
System.Windows.Controls.Grid.MeasureOverride(Size constraint)<BR>   at
System.Windows.FrameworkElement.MeasureCore(Size availableSize)<BR>  
at System.Windows.UIElement.Measure(Size availableSize)<BR>   at
System.Windows.Controls.Control.MeasureOverride(Size constraint)<BR>  
at System.Windows.FrameworkElement.MeasureCore(Size
availableSize)<BR>   at System.Windows.UIElement.Measure(Size
availableSize)<BR>   at
MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size
constraint)<BR>   at
System.Windows.Controls.ContentPresenter.MeasureOverride(Size
constraint)<BR>   at System.Windows.FrameworkElement.MeasureCore(Size
availableSize)<BR>   at System.Windows.UIElement.Measure(Size
availableSize)<BR>   at
System.Windows.Controls.Border.MeasureOverride(Size constraint)<BR>  
at System.Windows.FrameworkElement.MeasureCore(Size
availableSize)<BR>   at System.Windows.UIElement.Measure(Size
availableSize)<BR>   at
System.Windows.Controls.Control.MeasureOverride(Size constraint)<BR>  
at System.Windows.FrameworkElement.MeasureCore(Size
availableSize)<BR>   at System.Windows.UIElement.Measure(Size
availableSize)<BR>   at
MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size
constraint)<BR>   at
System.Windows.Controls.ContentPresenter.MeasureOverride(Size
constraint)<BR>   at System.Windows.FrameworkElement.MeasureCore(Size
availableSize)<BR>   at System.Windows.UIElement.Measure(Size
availableSize)<BR>   at
System.Windows.Controls.Grid.MeasureOverride(Size constraint)<BR>   at
System.Windows.FrameworkElement.MeasureCore(Size availableSize)<BR>  
at System.Windows.UIElement.Measure(Size availableSize)<BR>   at
MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size
constraint)<BR>   at
System.Windows.Controls.ContentPresenter.MeasureOverride(Size
constraint)<BR>   at System.Windows.FrameworkElement.MeasureCore(Size
availableSize)<BR>   at System.Windows.UIElement.Measure(Size
availableSize)<BR>   at
System.Windows.Controls.Border.MeasureOverride(Size constraint)<BR>  
at System.Windows.FrameworkElement.MeasureCore(Size
availableSize)<BR>   at System.Windows.UIElement.Measure(Size
availableSize)<BR>   at
System.Windows.Controls.Border.MeasureOverride(Size constraint)<BR>  
at System.Windows.FrameworkElement.MeasureCore(Size
availableSize)<BR>   at System.Windows.UIElement.Measure(Size
availableSize)<BR>   at
System.Windows.Controls.Border.MeasureOverride(Size constraint)<BR>  
at System.Windows.FrameworkElement.MeasureCore(Size
availableSize)<BR>   at System.Windows.UIElement.Measure(Size
availableSize)<BR>   at
System.Windows.Controls.Border.MeasureOverride(Size constraint)<BR>  
at System.Windows.FrameworkElement.MeasureCore(Size
availableSize)<BR>   at System.Windows.UIElement.Measure(Size
availableSize)<BR>   at
System.Windows.Controls.Control.MeasureOverride(Size constraint)<BR>  
at System.Windows.FrameworkElement.MeasureCore(Size
availableSize)<BR>   at System.Windows.UIElement.Measure(Size
availableSize)<BR>   at System.Windows.Controls.Grid.MeasureCell(Int32
cell, Boolean forceInfinityV)<BR>   at
System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size
referenceSize, Boolean ignoreDesiredSizeU, Boolean
forceInfinityV)<BR>   at
System.Windows.Controls.Grid.MeasureOverride(Size constraint)<BR>   at
System.Windows.FrameworkElement.MeasureCore(Size availableSize)<BR>  
at System.Windows.UIElement.Measure(Size availableSize)<BR>   at
System.Windows.Controls.Control.MeasureOverride(Size constraint)<BR>  
at Telerik.Windows.Controls.TabControl.RadTabControlBase.MeasureOverride(Size
availableSize)<BR>   at
System.Windows.FrameworkElement.MeasureCore(Size availableSize)<BR>  
at System.Windows.UIElement.Measure(Size availableSize)<BR>   at
Telerik.Windows.Controls.ProportionalStackPanel.MeasureOverride(Size
availableSize)<BR>   at
System.Windows.FrameworkElement.MeasureCore(Size availableSize)<BR>  
at System.Windows.UIElement.Measure(Size availableSize)<BR>   at
MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size
constraint)<BR>   at
System.Windows.Controls.ItemsPresenter.MeasureOverride(Size
constraint)<BR>   at System.Windows.FrameworkElement.MeasureCore(Size
availableSize)<BR>   at System.Windows.UIElement.Measure(Size
availableSize)<BR>   at
System.Windows.Controls.Border.MeasureOverride(Size constraint)<BR>  
at System.Windows.FrameworkElement.MeasureCore(Size
availableSize)<BR>   at System.Windows.UIElement.Measure(Size
availableSize)<BR>   at
System.Windows.Controls.Grid.MeasureOverride(Size constraint)<BR>   at
System.Windows.FrameworkElement.MeasureCore(Size availableSize)<BR>  
at System.Windows.UIElement.Measure(Size availableSize)<BR>   at
System.Windows.Controls.Control.MeasureOverride(Size constraint)<BR>  
at System.Windows.FrameworkElement.MeasureCore(Size
availableSize)<BR>   at System.Windows.UIElement.Measure(Size
availableSize)<BR>   at
MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size
constraint)<BR>   at
System.Windows.Controls.ContentPresenter.MeasureOverride(Size
constraint)<BR>   at System.Windows.FrameworkElement.MeasureCore(Size
availableSize)<BR>   at System.Windows.UIElement.Measure(Size
availableSize)<BR>   at
System.Windows.Controls.Border.MeasureOverride(Size constraint)<BR>  
at System.Windows.FrameworkElement.MeasureCore(Size
availableSize)<BR>   at System.Windows.UIElement.Measure(Size
availableSize)<BR>   at
System.Windows.Controls.Control.MeasureOverride(Size constraint)<BR>  
at System.Windows.FrameworkElement.MeasureCore(Size
availableSize)<BR>   at System.Windows.UIElement.Measure(Size
availableSize)<BR>   at
Telerik.Windows.Controls.RadDockPanel.MeasureOverride(Size
availableSize)<BR>   at
Telerik.Windows.Controls.DockingPanel.MeasureOverride(Size
availableSize)<BR>   at
System.Windows.FrameworkElement.MeasureCore(Size availableSize)<BR>  
at System.Windows.UIElement.Measure(Size availableSize)<BR>   at
System.Windows.Controls.DockPanel.MeasureOverride(Size
constraint)<BR>   at System.Windows.FrameworkElement.MeasureCore(Size
availableSize)<BR>   at System.Windows.UIElement.Measure(Size
availableSize)<BR>   at
System.Windows.Controls.Border.MeasureOverride(Size constraint)<BR>  
at System.Windows.FrameworkElement.MeasureCore(Size
availableSize)<BR>   at System.Windows.UIElement.Measure(Size
availableSize)<BR>   at
System.Windows.Controls.Grid.MeasureOverride(Size constraint)<BR>   at
System.Windows.FrameworkElement.MeasureCore(Size availableSize)<BR>  
at System.Windows.UIElement.Measure(Size availableSize)<BR>   at
System.Windows.Controls.Control.MeasureOverride(Size constraint)<BR>  
at Telerik.Windows.Controls.RadDocking.MeasureOverride(Size
availableSize)<BR>   at
System.Windows.FrameworkElement.MeasureCore(Size availableSize)<BR>  
at System.Windows.UIElement.Measure(Size availableSize)<BR>   at
System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean
forceInfinityV)<BR>   at
System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size
referenceSize, Boolean ignoreDesiredSizeU, Boolean
forceInfinityV)<BR>   at
System.Windows.Controls.Grid.MeasureOverride(Size constraint)<BR>   at
System.Windows.FrameworkElement.MeasureCore(Size availableSize)<BR>  
at System.Windows.UIElement.Measure(Size availableSize)<BR>   at
System.Windows.Controls.DockPanel.MeasureOverride(Size
constraint)<BR>   at System.Windows.FrameworkElement.MeasureCore(Size
availableSize)<BR>   at System.Windows.UIElement.Measure(Size
availableSize)<BR>   at
MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size
constraint)<BR>   at
System.Windows.Controls.ContentPresenter.MeasureOverride(Size
constraint)<BR>   at System.Windows.FrameworkElement.MeasureCore(Size
availableSize)<BR>   at System.Windows.UIElement.Measure(Size
availableSize)<BR>   at
System.Windows.Controls.Border.MeasureOverride(Size constraint)<BR>  
at System.Windows.FrameworkElement.MeasureCore(Size
availableSize)<BR>   at System.Windows.UIElement.Measure(Size
availableSize)<BR>   at
System.Windows.Controls.Control.MeasureOverride(Size constraint)<BR>  
at System.Windows.FrameworkElement.MeasureCore(Size
availableSize)<BR>   at System.Windows.UIElement.Measure(Size
availableSize)<BR>   at
MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size
constraint)<BR>   at
System.Windows.Controls.ContentPresenter.MeasureOverride(Size
constraint)<BR>   at System.Windows.FrameworkElement.MeasureCore(Size
availableSize)<BR>   at System.Windows.UIElement.Measure(Size
availableSize)<BR>   at
System.Windows.Documents.AdornerDecorator.MeasureOverride(Size
constraint)<BR>   at System.Windows.FrameworkElement.MeasureCore(Size
availableSize)<BR>   at System.Windows.UIElement.Measure(Size
availableSize)<BR>   at
System.Windows.Controls.Border.MeasureOverride(Size constraint)<BR>  
at System.Windows.FrameworkElement.MeasureCore(Size
availableSize)<BR>   at System.Windows.UIElement.Measure(Size
availableSize)<BR>   at
System.Windows.Window.MeasureOverrideHelper(Size constraint)<BR>   at
System.Windows.Window.MeasureOverride(Size availableSize)<BR>   at
System.Windows.FrameworkElement.MeasureCore(Size availableSize)<BR>  
at System.Windows.UIElement.Measure(Size availableSize)<BR>   at
System.Windows.ContextLayoutManager.UpdateLayout()<BR>   at
System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object
arg)<BR>   at
System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()<BR>  
at
System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()<BR>  
at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object
resizedCompositionTarget)<BR>   at
System.Windows.Media.MediaContext.RenderMessageHandler(Object
resizedCompositionTarget)<BR>   at
System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback,
Object args, Int32 numArgs)<BR>   at
MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate
method, Object args, Int32 numArgs, Delegate catchHandler)<BR>

The persisted stream contains the following string:

<?xml version="1.0"?><BR><RawData xmlns:xsi="<A href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance<;/A>"
xmlns:xsd="<A
<SerializationString>&lt;?xml version="1.0"
encoding="utf-16"?&gt;<BR>&lt;Data xmlns:xsi="<A href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance<;/A>"
xmlns:xsd="<A href="http://www.w3.org/2001/XMLSchema"
&gt?="">http://www.w3.org/2001/XMLSchema"&gt</A>;<BR> 
&lt;T&gt;<BR>    &lt;TI K="-1096199086"
N="Telerik.Windows.Controls.RadGridView, Telerik.Windows.Controls.GridView,
Version=2012.1.215.40, Culture=neutral, PublicKeyToken=5803cfa389c90ce7"
/&gt;<BR>    &lt;TI K="-664072138" N="System.String,
mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
/&gt;<BR>    &lt;TI K="883639814" N="System.Int32,
mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
/&gt;<BR>    &lt;TI K="1938418300"
N="Telerik.Windows.Controls.GridViewLength, Telerik.Windows.Controls.GridView,
Version=2012.1.215.40, Culture=neutral, PublicKeyToken=5803cfa389c90ce7"
/&gt;<BR>    &lt;TI K="1062653933"
N="Telerik.Windows.Controls.GridView.GridViewLengthConverter,
Telerik.Windows.Controls.GridView, Version=2012.1.215.40, Culture=neutral,
PublicKeyToken=5803cfa389c90ce7" /&gt;<BR>    &lt;TI
K="-1936503569" N="WpfView.Utils.ColumnProxy, WpfView, Version=2011.1.419.0,
Culture=neutral, PublicKeyToken=null" /&gt;<BR>    &lt;TI
K="542981235" N="System.Collections.Generic.List`1[[WpfView.Utils.ColumnProxy,
WpfView, Version=2011.1.419.0, Culture=neutral, PublicKeyToken=null]], mscorlib,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
/&gt;<BR>    &lt;TI K="168782652"
N="System.Collections.Generic.List`1[[WpfView.Utils.SortDescriptorProxy,
WpfView, Version=2011.1.419.0, Culture=neutral, PublicKeyToken=null]], mscorlib,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
/&gt;<BR>    &lt;TI K="-896951768"
N="System.Collections.Generic.List`1[[WpfView.Utils.FilterSetting, WpfView,
Version=2011.1.419.0, Culture=neutral, PublicKeyToken=null]], mscorlib,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
/&gt;<BR>    &lt;TI K="-1353305985"
N="System.Collections.Generic.List`1[[WpfView.Utils.GroupDescriptorProxy,
WpfView, Version=2011.1.419.0, Culture=neutral, PublicKeyToken=null]], mscorlib,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
/&gt;<BR>  &lt;/T&gt;<BR> 
&lt;P&gt;<BR>    &lt;PV Key="-1" TypeKey="0"
/&gt;<BR>    &lt;PV Key="1"
TypeKey="883639814"&gt;<BR>      &lt;Value
xsi:type="xsd:int"&gt;0&lt;/Value&gt;<BR>   
&lt;/PV&gt;<BR>    &lt;PV Key="2"
TypeKey="-664072138"&gt;<BR>      &lt;Value
xsi:type="xsd:string"&gt;System.Windows.Controls.Label:
Name&lt;/Value&gt;<BR>   
&lt;/PV&gt;<BR>    &lt;PV Key="3"
TypeKey="-664072138"&gt;<BR>      &lt;Value
xsi:type="xsd:string"&gt;*&lt;/Value&gt;<BR>   
&lt;/PV&gt;<BR>    &lt;PV Key="4"
TypeKey="883639814"&gt;<BR>      &lt;Value
xsi:type="xsd:int"&gt;1&lt;/Value&gt;<BR>   
&lt;/PV&gt;<BR>    &lt;PV Key="5"
TypeKey="-664072138"&gt;<BR>      &lt;Value
xsi:type="xsd:string"&gt;System.Windows.Controls.Label: Date Of
Birth&lt;/Value&gt;<BR>    &lt;/PV&gt;<BR> 
&lt;/P&gt;<BR>  &lt;R&gt;<BR>    &lt;RV
Key="65465420" IsRoot="true"
TypeKey="-1096199086"&gt;<BR>     
&lt;D&gt;<BR>        &lt;PD
PN="Columns" VK="0" RK="14266522" TK="542981235" TCK="0"
/&gt;<BR>        &lt;PD
PN="SortDescriptors" VK="0" RK="57577169" TK="168782652" TCK="0"
/&gt;<BR>        &lt;PD
PN="FilterDescriptors" VK="0" RK="16240409" TK="-896951768" TCK="0"
/&gt;<BR>        &lt;PD
PN="GroupDescriptors" VK="0" RK="53930216" TK="-1353305985" TCK="0"
/&gt;<BR>     
&lt;/D&gt;<BR>   
&lt;/RV&gt;<BR>    &lt;RV Key="24159481"
IsRoot="false" TypeKey="0"&gt;<BR>     
&lt;D&gt;<BR>        &lt;PD
PN="UniqueName" VK="-1" RK="0" TK="-664072138" TCK="0"
/&gt;<BR>        &lt;PD
PN="DisplayOrder" VK="1" RK="0" TK="883639814" TCK="0"
/&gt;<BR>        &lt;PD PN="Header"
VK="2" RK="0" TK="-664072138" TCK="0"
/&gt;<BR>        &lt;PD PN="Width"
VK="3" RK="0" TK="1938418300" TCK="1062653933"
/&gt;<BR>     
&lt;/D&gt;<BR>   
&lt;/RV&gt;<BR>    &lt;RV Key="14266522"
IsRoot="false" TypeKey="542981235"&gt;<BR>     
&lt;D&gt;<BR>        &lt;PD
PN="Columns[]" VK="0" RK="24159481" TK="-1936503569" TCK="0"
/&gt;<BR>        &lt;PD
PN="Columns[]" VK="0" RK="51014632" TK="-1936503569" TCK="0"
/&gt;<BR>     
&lt;/D&gt;<BR>   
&lt;/RV&gt;<BR>    &lt;RV Key="51014632"
IsRoot="false" TypeKey="0"&gt;<BR>     
&lt;D&gt;<BR>        &lt;PD
PN="UniqueName" VK="-1" RK="0" TK="-664072138" TCK="0"
/&gt;<BR>        &lt;PD
PN="DisplayOrder" VK="4" RK="0" TK="883639814" TCK="0"
/&gt;<BR>        &lt;PD PN="Header"
VK="5" RK="0" TK="-664072138" TCK="0"
/&gt;<BR>        &lt;PD PN="Width"
VK="3" RK="0" TK="1938418300" TCK="1062653933"
/&gt;<BR>     
&lt;/D&gt;<BR>    &lt;/RV&gt;<BR> 
&lt;/R&gt;<BR>&lt;/Data&gt;</SerializationString><BR> 
<ValueTypes><BR>   
<string>Telerik.Windows.Controls.RadGridView,
Telerik.Windows.Controls.GridView, Version=2012.1.215.40, Culture=neutral,
PublicKeyToken=5803cfa389c90ce7</string><BR>   
<string>System.String, mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089</string><BR>   
<string>System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089</string><BR>   
<string>Telerik.Windows.Controls.GridViewLength,
Telerik.Windows.Controls.GridView, Version=2012.1.215.40, Culture=neutral,
PublicKeyToken=5803cfa389c90ce7</string><BR>   
<string>Telerik.Windows.Controls.GridView.GridViewLengthConverter,
Telerik.Windows.Controls.GridView, Version=2012.1.215.40, Culture=neutral,
PublicKeyToken=5803cfa389c90ce7</string><BR>   
<string>WpfView.Utils.ColumnProxy, WpfView, Version=2011.1.419.0,
Culture=neutral, PublicKeyToken=null</string><BR>   
<string>System.Collections.Generic.List`1[[WpfView.Utils.ColumnProxy,
WpfView, Version=2011.1.419.0, Culture=neutral, PublicKeyToken=null]], mscorlib,
Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089</string><BR>   
<string>System.Collections.Generic.List`1[[WpfView.Utils.SortDescriptorProxy,
WpfView, Version=2011.1.419.0, Culture=neutral, PublicKeyToken=null]], mscorlib,
Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089</string><BR>   
<string>System.Collections.Generic.List`1[[WpfView.Utils.FilterSetting,
WpfView, Version=2011.1.419.0, Culture=neutral, PublicKeyToken=null]], mscorlib,
Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089</string><BR>   
<string>System.Collections.Generic.List`1[[WpfView.Utils.GroupDescriptorProxy,
WpfView, Version=2011.1.419.0, Culture=neutral, PublicKeyToken=null]], mscorlib,
Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089</string><BR> 
</ValueTypes><BR></RawData><BR>

I am using the libraries of version 2012.1.215.40. I am following the GridViewCustomSerialization project in the demos as a guide.

The gridview has only two columns and its AutoGenerateColumns property set to false.

I would appreciate if you could indicate what could cause this exception as soon as possible.

Regards,
Gajan



10 Answers, 1 is accepted

Sort by
0
Gajan
Top achievements
Rank 1
answered on 12 Mar 2012, 12:04 PM
Has anyone got a solution on the above please?

Best Regards,
Gajan
0
Tina Stancheva
Telerik team
answered on 14 Mar 2012, 10:39 AM
Hi Gajan,

I prepared a sample solution to test your scenario but I couldn't reproduce the exception. Please have a look at the attached sample and let me know if it works for you or if I'm missing something.

Kind regards,
Tina Stancheva
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Gajan
Top achievements
Rank 1
answered on 14 Mar 2012, 12:16 PM
Hi Tina,

Thanks for the reply. I have solved the 'index out of range' exception by loading the stream in the loaded event of the control. I think I was loading it too soon which caused the exception.

However, I am still having issues with loading the GridView. On loading the stream, the columns got swapped and one of the headers is not displayed properly.

You can replicate this issue by copying the following code in the sample source you provided.

MainWindow.xaml
<Window x:Class="PersistingGridViewInStream.MainWindow"
        Title="MainWindow"
        Width="525"
        Height="350">
    <Window.Resources>
    <Style TargetType="{x:Type ContentControl}" x:Key="PersonManager">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ContentControl}">    
                     
    <Grid MinWidth="700" MinHeight="500">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <StackPanel Margin="3">
            <telerik:RadButton x:Name="buttonSave"
                               Margin="0 2"
                               Click="OnSave"
                               Content="Save" />
            <telerik:RadButton x:Name="buttonLoad"
                               Margin="0 2"
                               Click="OnLoad"
                               Content="Load" />
        </StackPanel>
        <telerik:RadGridView x:Name="gridView"
                             Grid.Column="1"
                             ItemsSource="{Binding}"
                             AutoGenerateColumns="False"
                             IsReadOnly="True"
                             ShowGroupPanel="False"
                             RowIndicatorVisibility="Hidden"
                             IsFilteringAllowed="False"
                             CanUserFreezeColumns="False"
                             ColumnWidth="*"
                             >
                                <telerik:RadGridView.Columns>
                                    <telerik:GridViewDataColumn>
                                        <telerik:GridViewDataColumn.Header>
                                            <Label Content="Customer Id" />
                                        </telerik:GridViewDataColumn.Header>
                                        <telerik:GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding CustomerID}" />
                                            </DataTemplate>
                                        </telerik:GridViewColumn.CellTemplate>
                                    </telerik:GridViewDataColumn>
 
 
                                    <telerik:GridViewDataColumn>
                                        <telerik:GridViewDataColumn.Header>
                                            <Label Content="CompanyName" />
                                        </telerik:GridViewDataColumn.Header>
                                        <telerik:GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding CompanyName}" />
                                            </DataTemplate>
                                        </telerik:GridViewColumn.CellTemplate>
                                    </telerik:GridViewDataColumn>
                                </telerik:RadGridView.Columns>
        </telerik:RadGridView>
 
    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>    </Window.Resources>
 
    <ContentControl
        x:Name="contentControl"
        Style="{StaticResource PersonManager}"
                ></ContentControl>   
     
</Window>

MainWindow.xaml.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Telerik.Windows.Persistence.Services;
using Telerik.Windows.Controls;
using Telerik.Windows.Persistence;
 
namespace PersistingGridViewInStream
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        System.IO.Stream stream;
        private string layoutToPersist;
 
        public MainWindow()
        {
            InitializeComponent();
 
            // register the custom property provider for the RadGridView:
            ServiceProvider.RegisterPersistenceProvider<ICustomPropertyProvider>(typeof(RadGridView), new GridViewCustomPropertyProvider());
            this.DataContext = ExamplesDB.GetCustomers();
            this.EnsureLoadState();
 
        }
        private void OnSave(object sender, System.Windows.RoutedEventArgs e)
        {
            PersistenceManager manager = new PersistenceManager();
 
            //contentControl.ApplyTemplate();
            var uiElement = contentControl.Template.FindName("gridView", contentControl) as RadGridView;
            if (uiElement == null)
                return;
            this.stream = manager.Save(uiElement);
 
            stream.Position = 0;
            var streamReader = new StreamReader(stream);
            layoutToPersist = streamReader.ReadToEnd();
             
            this.EnsureLoadState();
 
        }
 
        private void OnLoad(object sender, System.Windows.RoutedEventArgs e)
        {
            stream = new MemoryStream(System.Text.ASCIIEncoding.UTF8.GetBytes(layoutToPersist));
 
            this.stream.Position = 0L;
            PersistenceManager manager = new PersistenceManager();
 
            var uiElement = contentControl.Template.FindName("gridView", contentControl) as RadGridView;
            if (uiElement == null)
                return;
 
            manager.Load(uiElement, this.stream);
            this.EnsureLoadState();
         
        }
        private bool CanLoad()
        {
            return this.stream != null && this.stream.Length > 0;
        }
 
        private void EnsureLoadState()
        {
 
        }
 
    }
}

As you would notice, the girdview is part of a controltemplate defined in a style which is applied to a content control.

Hoping to hear from you soon.

Best Regards,

Gajan






0
Tina Stancheva
Telerik team
answered on 19 Mar 2012, 09:46 AM
Hello Gajan,

Thank you for sending the code snippets. I noticed that you're using a Label to define the Header of the  columns. However, the custom GridViewCustomPropertyProvider expects a string so you need to modify it to persist the content of the label. For example you can change the ColumnProxy class Header property to be of type object. And you can to take the header of the columns as a Label or a ContentControl and change the ProvideValue/RestoreValue methods to take the content of the Label/ContentControl.

Also the columns cannot be properly differentiated as they don't have a UniqueName property set. Please set this property as it is used by the GridViewCustomPropertyProvider to distinguish the columns.

I modified my solution accordingly. Give it a try and let me know if it helps.

All the best,
Tina Stancheva
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Gajan
Top achievements
Rank 1
answered on 29 Mar 2012, 03:13 PM
Hi Tina,

Thank you for your advise and it solved the problem to a certain extent. 

I have set the UniqueName property for each column. I have removed Header property from ColumnProxy class as I am binding the header value and do not want to persist and load.

This works, however, after a few iterations of saving and loading, the value for 'proxy.DisplayOrder' of all columns are somehow set to -1 when saving and causes exception on loading the next time (at the following line in RestoreValue method). 

column.DisplayIndex = proxy.DisplayOrder;

I cannot find any pattern on when this happens (DisplayOrder getting set to -1) and it appears random. 

Hope to hearing from you soon.

Best Regards,
Gajan
0
Tina Stancheva
Telerik team
answered on 03 Apr 2012, 03:20 PM
Hello Gejan,

Usually the DisplayIndex of all columns that aren't fully initialized is -1. And if in your application at a certain point you're saving the column settings of a grid that isn't fully initialized or it's not initialized at all, such an issue may arise.

However as I am not sure how you've implemented your scenario and how you go through the save/load iterations, I am not sure if this is indeed the reason for the issue. But if you can send us a sample solution reproducing it, we will be able to further investigate the cause.

Kind regards,
Tina Stancheva
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Raj Yennam
Top achievements
Rank 1
answered on 05 Sep 2012, 12:40 PM
Hi Tina,

I am also getting the same problem (DisplayIndex for all columns is assigned to -1). Could you please help me to resolve the problem.

Note: In one view it is working fine(returning proper DisplayIndex for each column) but some other view its returning -1.

Thanks
Raj
0
Tina Stancheva
Telerik team
answered on 05 Sep 2012, 12:44 PM
Hi Raj,

In the views where the DisplayIndex is -1, perhaps the PersistenceFramework Save logic is implemented too early - while the RadGridView hasn't fully loaded and initialized its columns. If you can send over a sample solution demonstrating your approach and the issue, we will be able to suggest how to modify the persistence logic to make sure the RadGridView settings are properly saved.

Regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Raj Yennam
Top achievements
Rank 1
answered on 06 Sep 2012, 09:13 AM
Hi Tina,

Thanks for your reply.

Since i am getting the below error message, i am not able to upload the solution zip file. Evenafter changed the extension to .png.
i have upload the screenshot of my usercontrol codebehind.

Reply to thread cannot be created because:
  • Please upload valid files: .jpg,.jpeg,.gif,.png smaller than 2MB.

I am able to store and restore the settings using button events. but i need this task to be done on load and unload events.
I have tried to load the settings on usercontrol loaded event and gridview loaded event both failed. 

Note: I would like to load the settings from IsolatedStorage on loading the view and save the changes on leaving the view. 

Thanks
Raj
0
Tina Stancheva
Telerik team
answered on 11 Sep 2012, 08:10 AM
Hi Raj,

The forums only allow small image attachments and this is why we encourage our customers to use the support ticketing system when they need to describe a specific case and attach their scenario implementation.

However, the snapshot you sent helped me better understand your case and the issue is really caused by the fact that you're trying to load the RadGridView persisted settings too early. When the control is loaded, the RadGridView isn't yet fully initialized and its columns aren't yet generated completely and their DisplayIndex is still -1. This is why it's best to call the LoadState() method using a Dispatcher in the RadGridView.Loaded event handler. This why you'll be sure that the control is fully loaded and ready to get its restored settings.

From the snapshot you sent, it seems to me that your application is targeting Silverlight and this is why I attached a sample solution demonstrating how to load the RadGridView settings when the application has loaded and how to save the state of the control, when you exit the application. Even if you're targeting WPF, you can still use the same approach.

Kind regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
PersistenceFramework
Asked by
Gajan
Top achievements
Rank 1
Answers by
Gajan
Top achievements
Rank 1
Tina Stancheva
Telerik team
Raj Yennam
Top achievements
Rank 1
Share this question
or