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

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

2 Answers 292 Views
Window
This is a migrated thread and some comments may be shown as answers.
GPJ
Top achievements
Rank 1
GPJ asked on 27 Feb 2009, 05:46 PM
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"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    BorderBrush="#FF192554"
    HorizontalAlignment="Stretch"
    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">
                <telerikGridView:RadGridView.Columns>
                    <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"/>
                </telerikGridView:RadGridView.Columns>
            </telerikGridView:RadGridView>
        </Grid>
        <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"/>
    </Grid>
</UserControl>

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);
            window.Hide();
        }

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 Answers, 1 is accepted

Sort by
0
Hristo Borisov
Telerik team
answered on 03 Mar 2009, 11:03 AM
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.
0
Theron Kousek
Top achievements
Rank 1
answered on 10 Mar 2009, 11:30 AM
Hi

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..).  



Tags
Window
Asked by
GPJ
Top achievements
Rank 1
Answers by
Hristo Borisov
Telerik team
Theron Kousek
Top achievements
Rank 1
Share this question
or