Error 'Value does not fall within the expected range'

10 posts, 0 answers
  1. Ron
    Ron avatar
    15 posts
    Member since:
    Jan 2009

    Posted 18 Mar 2009 Link to this post

    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
  2. Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 18 Mar 2009 Link to this post

    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.
  3. DevCraft banner
  4. Ron
    Ron avatar
    15 posts
    Member since:
    Jan 2009

    Posted 18 Mar 2009 Link to this post

    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.
  5. Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 18 Mar 2009 Link to this post

    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.
  6. Ron
    Ron avatar
    15 posts
    Member since:
    Jan 2009

    Posted 18 Mar 2009 Link to this post

    No :-(
    I got 'Object reference not set to an instance of an object'.
  7. Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 19 Mar 2009 Link to this post

    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.
  8. Ron
    Ron avatar
    15 posts
    Member since:
    Jan 2009

    Posted 26 Mar 2009 Link to this post

    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
  9. Ron
    Ron avatar
    15 posts
    Member since:
    Jan 2009

    Posted 26 Mar 2009 Link to this post

    Eventually, I managed to open a support ticket.
    My ticket ID is: 200727.

    Thanks.
  10. Nuno
    Nuno avatar
    53 posts
    Member since:
    Dec 2007

    Posted 15 Jul 2011 Link to this post


    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

  11. Tsvyatko
    Admin
    Tsvyatko avatar
    833 posts

    Posted 15 Jul 2011 Link to this post

    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!

Back to Top
DevCraft banner