When I want to reopen the first RadWindow I get the exception: " Value does not fall within the expected range"
Heeeelp!!! =(
15 Answers, 1 is accepted
Thanks
The error is caused by the RadTreeView that was within the first RadWindow when select an item, close the window, when you reopen the window caused the error, because he had left an Item selected in the RadTreeView.
I tried to give the value "false" RadTreeViewItem.IsSelected property did not work.
Thank you!
This seems like a bug in the TreeView.
Can you please send us the CallStack when the exception happens?
Please uncheck "Tools -> Options -> Debugging -> Enable Just My Code".
Thank you for helping us identify this issue.
Regards,
Miroslav
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
en MS.Internal.XcpImports.MethodEx(IntPtr ptr, String name, CValue[] cvData)
en MS.Internal.XcpImports.MethodPack(IntPtr objectPtr, String methodName, Object[] rawData)
en MS.Internal.XcpImports.Collection_Add[T](PresentationFrameworkCollection`1 collection, Object value)
en System.Windows.PresentationFrameworkCollection`1.AddImpl(Object value)
en System.Windows.Controls.ItemCollection.AddImpl(Object value)
en System.Windows.Controls.ItemCollection.AddInternal(Object value)
en System.Windows.PresentationFrameworkCollection`1.Add(T value)
en ReqMaterial.Presentacion.Silverlight.Views.formSolicitud.consSolReqMaterial.cliente_consulta_PartidasAutorizarCompleted(Object sender, consulta_PartidasAutorizarCompletedEventArgs e)
The exception "Value does not fall within the expected range" is thrown when an object that already exists in the visual tree of the appellation is added to it again. From your callstack it seems that this is what is happening, i.e. this method:
ReqMaterial.Presentacion.Silverlight.Views.formSolicitud.consSolReqMaterial.cliente_consulta_PartidasAutorizarCompleted(Object sender, consulta_PartidasAutorizarCompletedEventArgs e)
adds something to the visual tree that has not been removed from its previous parent:
System.Windows.PresentationFrameworkCollection`1.Add(T value)
Unfortunately I cannot guess what this may be. What happens in your code when all items in the TreeView are deselected? It seems that it is related to the error.
If you could send us a project where the exception occurs, I will be happy to help you.
All the best,
Miroslav
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
The exception and occurs when the tree is loaded first. I've been seeing that in executing the application, load normally, other occasions that exception occurs.
Unfortunately I can not send the project, because I have no privileges on my account even send the projects.
Thanks and greetings!
Could you share the code in this method?
ReqMaterial.Presentacion.Silverlight.Views.formSolicitud.consSolReqMaterial.cliente_consulta_PartidasAutorizarCompleted(Object sender, consulta_PartidasAutorizarCompletedEventArgs e)
It seems that something there is causing the exception.
All the best,
Miroslav
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
This same method you ask:
void
cliente_consulta_PartidasAutorizarCompleted(object sender, consulta_PartidasAutorizarCompletedEventArgs e)
{
try
{
for (int i = 0; i < e.Result.Count; i++)
{
radTreVieParProgramacion.Items.Add(Agregar_TreVieItem(e.Result[i]));
}
}
catch (Exception parException)
{
}
}
This is the method that creates the TreeViewItem:
RadTreeViewItem
Agregar_TreVieItem(object parObjGenerico)
{
try
{
RadTreeViewItem newRadItem = new RadTreeViewItem();
Type TypObjeto = parObjGenerico.GetType();
if (TypObjeto.Name == "objEntSolicitud")
{
objEntSolicitud objGenerico = (objEntSolicitud)parObjGenerico;
newRadItem.Header =
"Sol." + objGenerico.numIdeParEncabezado + " " + objGenerico.carDesBodega + " [" + objGenerico.carNomUsuario + "]";
newRadItem.Name = objGenerico.numIdeParEncabezado.ToString();
newRadItem.Tag = objGenerico;
newRadItem.SetValue(
ToolTipService.ToolTipProperty, newRadItem.Header);
newRadItem.DefaultImageSrc =
"../../Imagen/Button/folder_solicitud.png";
return newRadItem;
}
else if (TypObjeto.Name == "objEntSolicitudDetalle")
{
objEntSolicitudDetalle objGenerico = (objEntSolicitudDetalle)parObjGenerico;
newRadItem.Header = objGenerico.carDesProducto +
" [" + objGenerico.numCanSolicitada + " " + objGenerico.carDesUniMedida + "]";
newRadItem.Name = objGenerico.numIdeParDetalle.ToString();
newRadItem.Tag = objGenerico;
newRadItem.SetValue(
ToolTipService.ToolTipProperty, newRadItem.Header);
newRadItem.DefaultImageSrc =
"../../Imagen/Button/partida.png";
return newRadItem;
}
else if (TypObjeto.Name == "objEntParProgramacion")
{
objEntParProgramacion objGenerico = (objEntParProgramacion)parObjGenerico;
newRadItem.Header = objGenerico.carDesProducto +
" [" + objGenerico.numCanProgramada + "]";
newRadItem.Name = objGenerico.numIdeParProgramacion.ToString();
newRadItem.Tag = objGenerico;
newRadItem.SetValue(
ToolTipService.ToolTipProperty, newRadItem.Header);
newRadItem.DefaultImageSrc =
"../../Imagen/Button/partida.png";
return newRadItem;
}
else if (TypObjeto.Name == "objEntTransMaterial")
{
objEntTransMaterial objGenerico = (objEntTransMaterial)parObjGenerico;
newRadItem.Header = objGenerico.carDescripcion;
newRadItem.Name = objGenerico.numIdeTransMaterial.ToString();
newRadItem.Tag = objGenerico;
newRadItem.SetValue(
ToolTipService.ToolTipProperty, newRadItem.Header);
newRadItem.DefaultImageSrc =
"../../Imagen/Button/carpeta.png";
return newRadItem;
}
return new RadTreeViewItem();
}
catch (Exception parException)
{
return new RadTreeViewItem();
}
}
This line here may be the reason for the problem:
newRadItem.Name = objGenerico.numIdeParEncabezado.ToString();
it appears to me that quite possibly two items with the same name could be created in the same namescope. Namescopes can be surprising in Silverlight, even if an object is not visible (like a closed window) it may still be part of the current namescope.
Could you try commenting the line to check whether the error is resolved. If it indeed is so, you may have to make sure that items with equal names are not added and that items are removed from their namescope before adding items with the same names.
Does this work for you?
Regards,
Miroslav
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Quite possibly the two windows share the same namescope.
Do you see the exception if the names are not set?
We have no control over the namescopes in Silverlight, they are determined by the visual tree and whether the item is a part of a Template (DataTemplate or ControlTemplate), possibly other rules that I am not aware of.
Regards,
Miroslav
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
I think it's better that way and better to store the value in the Tag parameter.
Miroslav'd appreciate your help, I was going crazy = P.
thanks =)
I understand that you have no control over the namescope but could you give a better error message? This message is only confusing the issue. I am getting the same error message but it is not resolved by following this thread (I don't name my controls) so the same error message is obviously generated by something else
"Value does not fall within the expected range" may occur in other scenarios different from the one described in this old thread. Yes, you are right, we cannot control how namescope in Silverlight works, furthermore we cannot override such system (Framework) exceptions.
We highly suggest you to open a new support thread with more details on your scenario and the steps you perform when reproducing the issue. This way we would be better able to investigate your case and you will receive a much faster response.
Thank you in advance for your cooperation.
Petar Mladenov
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.