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

Exception "Value does not fall within the expected range" when displaying nested Rad Windows

2 Answers 508 Views
Window
This is a migrated thread and some comments may be shown as answers.
imusic
Top achievements
Rank 2
imusic asked on 06 Feb 2009, 12:42 PM

I have PopUpControl that on button click shows RadWindow. Content of RadWindow is PopUpWindow. I dynamically load PopUpWindow content which in turn can contains PopUpControl.

First popup displays fine, however on nested popup I get following exception:

System.ArgumentException was unhandled by user code
  Message="Value does not fall within the expected range."
  StackTrace:
       at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       at MS.Internal.XcpImports.Collection_InsertValue[T](PresentationFrameworkCollection`1 collection, UInt32 index, CValue value)
       at MS.Internal.XcpImports.Collection_InsertDependencyObject[T](PresentationFrameworkCollection`1 collection, UInt32 index, DependencyObject value)
       at System.Windows.PresentationFrameworkCollection`1.InsertDependencyObject(Int32 index, DependencyObject value)
       at System.Windows.Controls.UIElementCollection.InsertInternal(Int32 index, UIElement value)
       at System.Windows.PresentationFrameworkCollection`1.Insert(Int32 index, T value)
       at Telerik.Windows.Controls.HACKS.AttachPopupToVisualTree(Popup popup)
       at Telerik.Windows.Controls.PopupManager.Open(Popup popup)
       at Telerik.Windows.Controls.PopupManager.OpenWindow(Popup popup)
       at Telerik.Windows.Controls.PopupManager.Open(Popup popup, PopupType type)
       at Telerik.Windows.Controls.RadWindow.ShowWindow()
       at Telerik.Windows.Controls.RadWindow.Show()
       at RadWindowPopup.PopupControl.ShowPopup_Click(Object sender, RoutedEventArgs e)
       at System.Windows.Controls.Primitives.ButtonBase.OnClick()
       at System.Windows.Controls.Button.OnClick()
       at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
       at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
       at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)
  InnerException:

I have small project that recreates this problem.

Is there a workaround for this issue?

2 Answers, 1 is accepted

Sort by
0
Serrin
Top achievements
Rank 1
answered on 06 Feb 2009, 08:58 PM
Hello,

I'd definitely be curious to see the xaml/cs that you are using for this, as I just tested a popup which opens a RadWindow, containing a RadCombo (which works), and a button which loads another RadWindow.  So I'm curious what your setup is that causes this. :)

My guess is that it has something to do with the popup control problem in the framework referenced here, but can't be sure as the problems in that forum post are resolved for me. 

I like looking at that exception though...  Telerik.Windows.Controls.HACKS -> fixing the Microsoft framework from within Telerik controls?  Nice. :)
0
imusic
Top achievements
Rank 2
answered on 10 Feb 2009, 11:30 AM

 

 

 

 

Workaround for this problem is to create class that manages hiding and showing Rad Windows and make sure there is only one RadWindow visible at the time.

Here are steps to recreate the issue:

1.       Create new C# Silverlight application and call it RadWindowPopup.

2.       Add reference to Telerik.Windows.Controls.dll and Telerik.Windows.Controls.Navigation.dll.

3.       Add new Silverlight control and call it PopupControl.

4.       Add another Silverlight control and call  it PopupWindow.

5.       Enter this for Page.xaml:

<UserControl x:Class="RadWindowPopup.Page"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:this="clr-namespace:RadWindowPopup;assembly=RadWindowPopup"

    Width="400" Height="300">

    <Grid x:Name="LayoutRoot">

        <this:PopupControl/>

    </Grid>

</UserControl>

6.       Enter this for PopupControl.xaml:

<UserControl x:Class="RadWindowPopup.PopupControl"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"

    xmlns:this="clr-namespace:RadWindowPopup;assembly=RadWindowPopup"

    Width="400" Height="300">

    <Grid x:Name="LayoutRoot" Background="White">

        <Grid.RowDefinitions>

            <RowDefinition Height="30"/>

        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>

            <ColumnDefinition Width="*" />

            <ColumnDefinition Width="30" />

            <ColumnDefinition Width="0" />

        </Grid.ColumnDefinitions>

        <TextBlock Grid.Column="0" >Click ... to open popup</TextBlock>

        <Button x:Name="ShowPopup" Click="ShowPopup_Click" Grid.Column="1">

            <TextBlock>...</TextBlock>

        </Button>

        <telerik:RadWindow Grid.Column="2" x:Name="RadWindow">

            <this:PopupWindow x:Name="PopupWindow" />

        </telerik:RadWindow>

    </Grid>

</UserControl>

7.       Enter this for PopupControl.xaml.cs

using System;

using System.Windows;

using System.Windows.Controls;

namespace RadWindowPopup

{

    public partial class PopupControl : UserControl

    {

        public PopupControl()

        {

            InitializeComponent();

        }

 

        private void ShowPopup_Click(object sender, RoutedEventArgs e)

        {

            PopupWindow.LoadDynamicContent();

            RadWindow.Show();

 

        }

    }

}

8.  Enter this for PopupWindow.xaml:

using System;

using System.Windows;

using System.Windows.Controls;

 

namespace RadWindowPopup

{

    public partial class PopupWindow : UserControl

    {

        public PopupWindow()

        {

            InitializeComponent();

        }

 

        public void LoadDynamicContent()

        {

            LayoutRoot.Children.Add(new PopupControl());

        }

 

    }

}

9.       Build and Run the project

10.   Click on … to display popup window

11.   Click on … in popup window – you should get:

 System.ArgumentException

  Message="Value does not fall within the expected range."

Tags
Window
Asked by
imusic
Top achievements
Rank 2
Answers by
Serrin
Top achievements
Rank 1
imusic
Top achievements
Rank 2
Share this question
or