Cannot insert a new uilelement in the real drop target.

Apr 11, 2010 at 10:53 PM

I have a DropTarget where Ghost is a Grid.

Grid gridRootWindowDT = new Grid(){Name = "gridRootWindowDT",HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch,VerticalAlignment = System.Windows.VerticalAlignment.Stretch,Width = 350,Height = 350,Background = new SolidColorBrush(Colors.DarkGray)};

<font face="Consolas" size="2"><font face="Consolas" size="2">

 

</font></font><font face="Consolas" size="2">

 

</font>

DropTarget dropTarget1 = new DropTarget() { Ghost = gridRootWindow,HorizontalAlignment.Stretch,VerticalAlignment.Stretch,new SolidColorBrush(Colors.DarkGray)};

The droptarhet is added to the children of the layour root.

In the entered event of the droptarget I try to insert a new button in the gridRootWindow ( I check to make sure it only happens once):

<font face="Consolas" size="2"><font face="Consolas" size="2">

IDEgridRootWindow.Children.Add(

</font></font><font face="Consolas" size="2">

 

</font>

new Button() { Name = "a2", Background = new SolidColorBrush(Colors.Brown), Width = 100, Height = 100 });

 

 I get an "Value Does not Fall within the Expected Range" error.

why? Tnx.