So I have two gridsplitters in my app and I want to persist wherever the user drags them across sessions. This mostly works but sometimes I seem to get this error whilst I am moving a gridsplitter and it locks and crashes the app:
An infinite loop appears to have resulted from repeatedly invalidating the TimeManager during the Layout/Render process
I don't know if this is a wild goose chase with the gridsplitters, but whenever I go back into the app, the gridsplitter positions revert back to their default positions and I haven't noticed it happen with any of the other controls that use the persistence framework.
So on my usercontrol with both gridsplitters I have the following code :
ServiceProvider.RegisterPersistenceProvider<ICustomPropertyProvider>(
typeof
(RadGridView),
new
GridViewCustomPropertyProvider());
SplitterCustomPropertyProvider splitterPropProvider =
new
SplitterCustomPropertyProvider();
ServiceProvider.RegisterPersistenceProvider<ICustomPropertyProvider>(
typeof
(RowDefinition), splitterPropProvider);
ServiceProvider.RegisterPersistenceProvider<ICustomPropertyProvider>(
typeof
(ColumnDefinition), splitterPropProvider);
SplitterCustomPropertyProvider is as so:
public
class
SplitterCustomPropertyProvider : ICustomPropertyProvider
{
public
CustomPropertyInfo[] GetCustomProperties()
{
// Create custom property to persist the pixels property on a column/row definition
return
new
CustomPropertyInfo[]
{
new
CustomPropertyInfo(
"GridSplitterPixels"
,
typeof
(
double
)),
};
}
public
void
InitializeObject(
object
context)
{
}
public
object
InitializeValue(CustomPropertyInfo customPropertyInfo,
object
context)
{
return
null
;
}
public
object
ProvideValue(CustomPropertyInfo customPropertyInfo,
object
context)
{
GridSplitterProxy proxy =
new
GridSplitterProxy();
if
(context
is
RowDefinition)
{
RowDefinition row = context
as
RowDefinition;
proxy.Pixels = row.ActualHeight;
return
proxy;
}
else
if
(context
is
ColumnDefinition)
{
ColumnDefinition row = context
as
ColumnDefinition;
proxy.Pixels = row.ActualWidth;
return
proxy;
}
return
null
;
}
public
void
RestoreValue(CustomPropertyInfo customPropertyInfo,
object
context,
object
value)
{
GridSplitterProxy proxy = value
as
GridSplitterProxy;
if
(context
is
RowDefinition)
{
RowDefinition row = context
as
RowDefinition;
if
(proxy.Pixels == 0)
row.Height =
new
GridLength(1, GridUnitType.Auto);
else
row.Height =
new
GridLength(proxy.Pixels);
}
else
if
(context
is
ColumnDefinition)
{
ColumnDefinition col = context
as
ColumnDefinition;
if
(proxy.Pixels == 0)
col.Width =
new
GridLength(1, GridUnitType.Auto);
else
col.Width =
new
GridLength(proxy.Pixels);
}
}
private
class
GridSplitterProxy
{
public
double
Pixels {
get
;
set
; }
}
}
The loading of the gridsplitter positions is done on the UserControl_Loaded event :
IsolatedStorageProvider isoStorageProvider =
new
IsolatedStorageProvider();
isoStorageProvider.LoadFromStorage();
And the saving of the positions is done on the MainWindow_Closing event :
IsolatedStorageProvider isoStorageProvider =
new
IsolatedStorageProvider();
isoStorageProvider.SaveToStorage();
Any ideas as to why I'm getting this error?