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

Error 'Value does not fall within the expected range'

9 Answers 433 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Ron
Top achievements
Rank 1
Ron asked on 18 Mar 2009, 07:47 AM
I tried to use Content tempalte in order to change the look of DragCue.
I use this code (very similar to your example):

1 ContentControl cue = new ContentControl();
2 cue.ContentTemplate = this.Resources["ShiftTemplateDragImage"] as DataTemplate;
3 cue.Content = lstTemplates.SelectedItem;
4 e.Options.DragCue = cue;

However, when I run my code I got an ecxeption of 'Value does not fall within the expected range' in the third line.
Stack Trace: 
  at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
   at MS.Internal.XcpImports.SetValue(INativeCoreTypeWrapper obj, DependencyProperty property, DependencyObject doh)
   at MS.Internal.XcpImports.SetValue(INativeCoreTypeWrapper doh, DependencyProperty property, Object obj)
   at System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)
   at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet, Boolean isSetByStyle, Boolean isSetByBuiltInStyle)
   at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value)
   at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
   at System.Windows.Controls.ContentControl.set_Content(Object value)
   at W6.ClickRoster.Views.W6CRShiftTemplates.OnDragQuery(Object sender, DragDropQueryEventArgs e)

Any ideas?

Thanks in advance

9 Answers, 1 is accepted

Sort by
0
Miroslav
Telerik team
answered on 18 Mar 2009, 08:10 AM
Hello Ron,

This error comes up when a visual item, already part of the visual tree (i.e. is generated and has a parent, may not be visible) is added to the visual tree again.

This may be the case with the IstTemplates.SelectedItem.
1. Can you confirm that it is not a visual item
2. If it is a visual item,  it is not part of the visual tree?

Hopefully this will work for you.

Kind regards,
Miroslav
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Ron
Top achievements
Rank 1
answered on 18 Mar 2009, 08:22 AM
Thanks for the quick response.

lstTemplates is a ListBox control that is defined in XAML. I added the event of OnDragQuery to this ListBox in the constructor of this class.
0
Miroslav
Telerik team
answered on 18 Mar 2009, 08:35 AM
Hi Ron,

Since the ListBox is defined in xaml, the SelectedItem may be a ListBoxItem which is a visual item and cannot be visible at two places at the same time.

If indeed the SelectedItem is a ListBoxItem, you can try using its content instead (but then its content also has to be a non-visual item, for the same limitation):

cue.Content = (IstTemplates.SelectedItem as ContentControl).Content;

Does this resolve the error?

Sincerely yours,
Miroslav
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Ron
Top achievements
Rank 1
answered on 18 Mar 2009, 08:59 AM
No :-(
I got 'Object reference not set to an instance of an object'.
0
Miroslav
Telerik team
answered on 19 Mar 2009, 06:08 PM
Hi Ron,

If the DragCue is not an existing visual element, I am not sure what else might be causing this error. 

Could you please provide a sample solution where the issue occurs, so that we will be able to help you quickly? 

You cannot upload directly in the forums, but you can open a support ticker if you wish.

Sincerely yours,
Miroslav
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Ron
Top achievements
Rank 1
answered on 26 Mar 2009, 07:34 AM
Hi,

I have a sample solution of my problem but I can't open a support ticket.
Any other idea how to send you this solution?

Thanks in advance
0
Ron
Top achievements
Rank 1
answered on 26 Mar 2009, 12:43 PM
Eventually, I managed to open a support ticket.
My ticket ID is: 200727.

Thanks.
0
Nuno
Top achievements
Rank 1
answered on 15 Jul 2011, 02:36 PM

Hi Telerik,

I'm having problems setting the DragCue property. I'm getting an exception you can see in the attached file.

My code used to work before upgrading to the 2011 Q2 version.

Here is the code where the problem exists:

private void OnDragQuery(object sender, DragDropQueryEventArgs e)
{
    try
    {
        if (sender is PartContainer)
        {
            e.QueryResult = true;
            if (e.Options.Status == DragStatus.DragQuery)
            {
                e.Options.DragCue = sender;
            }
        }
    }
    catch (Exception ex)
    {
        Global.logAgent.WriteLogEntry(ex);
    }
}

It breakes in this line =>e.Options.DragCue = sender;
Shows an ugly message box and doesn't event fall in the catch section.

I need help asap. Thanks a lot!

Nuno

0
Tsvyatko
Telerik team
answered on 15 Jul 2011, 04:15 PM
Hi Nuno,

 Please, check the answer in the corresponding thread - http://www.telerik.com/community/forums/silverlight/drag-and-drop/2011-q2-release---error-value-does-not-fall-within-the-expected-range.aspx

Kind regards,
Tsvyatko
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
DragAndDrop
Asked by
Ron
Top achievements
Rank 1
Answers by
Miroslav
Telerik team
Ron
Top achievements
Rank 1
Nuno
Top achievements
Rank 1
Tsvyatko
Telerik team
Share this question
or