Value does not fall within the expected range exception with RadGridView on RadWindow popup.

3 posts, 0 answers
  1. GPJ
    GPJ avatar
    31 posts
    Member since:
    Oct 2008

    Posted 27 Feb 2009 Link to this post

    Like so many others before me, I am experiencing this problem..  but with the RadGridView instead of the combo box or list box controls.  Here is my XAML..

    <UserControl x:Class="MyNamespace.MyActivities"
        VerticalAlignment="Stretch" Width="Auto" xmlns:telerikInput="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input" xmlns:telerikGridView="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView" xmlns:Telerik_Windows_Controls_GridView="clr-namespace:Telerik.Windows.Controls.GridView;assembly=Telerik.Windows.Controls.GridView">

        <Grid x:Name="LayoutRoot">
            <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Visibility="Visible" Width="990" Height="450" Background="{x:Null}">
                <telerikGridView:RadGridView Margin="0,0,0,0"  x:Name="gridActivities" IsTabStop="True" TabIndex="1" ColumnsWidthMode="None"  AutoGenerateColumns="False" IsReadOnly="True" ShowGroupPanel="False" FontSize="12" Height="400" VerticalAlignment="Top">
                        <Telerik_Windows_Controls_GridView:GridViewDataColumn HeaderText="Sent Date" DataMemberBinding="{Binding Path=SentDate}" Width="110" DataFormatString="{}{0:d-MMM-yyyy}" />
                        <Telerik_Windows_Controls_GridView:GridViewDataColumn HeaderText="Details"  DataMemberBinding="{Binding Path=Details}" Width="300"/>
                        <Telerik_Windows_Controls_GridView:GridViewDataColumn HeaderText="Sent To" DataMemberBinding="{Binding Path=ReceivingUser}" Width="240"/>
                        <Telerik_Windows_Controls_GridView:GridViewDataColumn HeaderText="Client" DataMemberBinding="{Binding Path=Client}" Width="160"/>
                        <Telerik_Windows_Controls_GridView:GridViewDataColumn HeaderText="ClientID" DataMemberBinding="{Binding Path=ClientID}" Width="110"/>
            <Button Content="Close" Height="30" IsTabStop="True" x:Name="btnClose" FontFamily="Portable User Interface" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="#FFFFFFFF" FontSize="14" Width="140" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Padding="0,0,0,0" HorizontalAlignment="Right" Margin="0,10,10,10" VerticalAlignment="Bottom"/>

    And my code-behind is pretty straightforward, but the close method does this:

            void btnClose_Click(object sender, RoutedEventArgs e)
                gridActivities.ItemsSource = null;
                RadWindow window = RadWindow.GetParentRadWindow(this);

    The only difference between it and some others I've seem is that I am setting the ItemsSource to null (because the next time it is shown, I may pass in a new datacontext). When I press the close button, everything is OK.  When I click the red X close (and I have CloseMode="Hide") I get the exception.  As a workaround I set CloseMode="none" but that doesn't instill a lot of confidence that it won't crash some other way.

    Any idea if this will be fixed in the Q12009 release (and any idea when its coming)?

  2. Hristo Borisov
    Hristo Borisov avatar
    298 posts

    Posted 03 Mar 2009 Link to this post

    Hi Greg Peter Joyal,

    I wasn't able to reproduce the problem from my initial tests, but one of the things that worries me is that you are using the GetParentRadWindow in an incorrect way. Method GetParentRadWindow recurses the visual tree for parent of type RadWindow, for example if you create a user control and set is as a content to RadWindow, you would need to use it in order to get a reference to the window itself. Would you try to remove this method, and instead initiate new instance of RadWindow in which you programatically set the GridView control as content to the window. Please feel free to contact us any soon.

    Best wishes,
    Hristo Borisov
    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 R3 2016 release webinar banner
  4. Theron Kousek
    Theron Kousek avatar
    12 posts
    Member since:
    Mar 2009

    Posted 10 Mar 2009 Link to this post


    We are getting that same issue.   This is not the best solution but should get you going until their next release.   I just went into

    private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)

    in App.xaml

    and added the following line

    e.Handled = true

    above the line.  

    if (!System.Diagnostics.Debugger.IsAttached)

    Basically just eating the exception.   A co-worker of mine went on a forum and saw that it was a Silverlight bug.   It has to do with navigating away from the page that has a grid view on it after you had focus in the gridview (ie, click a cell, etc..).  

Back to Top