Find a bug about obj.children.add/remove with Canvas.Triggers

When it is a Canvas.Triggers in a Canvas,

and I bind a javascript function on this Canvas,

if this function made this Canvas removed from it's parent object, and add into this parent object after removed ( just for the z-index effect ), the Canvas WILL BE run out of the eye

[296 byte] By [Cestlavie] at [2007-12-31]
# 1

<Canvas x:Name="desktop_tokei" Opacity="0"
MouseLeftButtonUp=ui_move_up"
MouseLeftButtonDown=ui_move_down"
MouseMove=ui_move_moving">
<Image x:Name="tokei_back" Source="pic/parts/tokei/tokei_back.png" Opacity="0.7"/>
<Image x:Name="tokei_long" Source="pic/parts/tokei/tokei_long.png">
<Image.RenderTransform>
<RotateTransform x:Name="tokei_hs_long" CenterX="100" CenterY="100" Angle="0"/>
</Image.RenderTransform>
</Image>
<Image x:Name="tokei_short" Source="pic/parts/tokei/tokei_short.png">
<Image.RenderTransform>
<RotateTransform x:Name="tokei_hs_short" CenterX="100" CenterY="100" Angle="0"/>
</Image.RenderTransform>
</Image>
<Image x:Name="tokei_second" Source="pic/parts/tokei/tokei_second.png">
<Image.RenderTransform>
<RotateTransform x:Name="tokei_hs_second" CenterX="100" CenterY="100" Angle="0"/>
</Image.RenderTransform>
</Image>
<Canvas.Triggers>
<EventTrigger>
<BeginStoryboard>
<Storyboard x:Name="desktop_tokei_on" BeginTime="1">
<DoubleAnimation
Storyboard.TargetName="desktop_tokei"
Storyboard.TargetProperty="Opacity"
To="1" Duration="0:0:0.5"/>
</Storyboard>
</BeginStoryboard>
<BeginStoryboard>
<Storyboard x:Name="desktop_tokei_off" BeginTime="1">
<DoubleAnimation
Storyboard.TargetName="desktop_tokei"
Storyboard.TargetProperty="Opacity"
To="0" Duration="0:0:0.5"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Canvas.Triggers>
</Canvas>

///////////////////////////////////////////////////////////////////javascript///////////////////////////////////////////////////////////////////

move:{
oldPointerOffset:null,
status:false,
up:function(s,e){
s.releaseMouseCapture();
ui.move.status=false;
},
down:function(s,e){
ui.up2front(s);
var _x=e.x-s["Canvas.Left"];
var _y=e.y-s["Canvas.Top"];
var _o={x:_x,y:_y}
ui.move.oldPointerOffset=_o;
s.captureMouse();
ui.move.status=true;
},

moving:function(s,e){
if(ui.move.status)
{
var op=ui.move.oldPointerOffset;
s["Canvas.Left"]=e.x-op.x;
s["Canvas.Top"]=e.y-op.y;
}
}

......

up2front:function(objStr,p){

try{if(!p)p=objStr.getParent;

p.children.remove(objStr);

p.children.add(objStr);}catch(e){}

},

...............


var ui_move_up=ui.move.up;
var ui_move_down=ui.move.down;
var ui_move_moving=ui.move.moving;

Cestlavie at 2007-9-6 > top of Msdn Tech,Silverlight (formerly WPF/E),Silverlight (formerly WPF/E) Developer Issues...
# 2

And I just remove the code of Canvas.Triggers, It turns OK.

Cestlavie at 2007-9-6 > top of Msdn Tech,Silverlight (formerly WPF/E),Silverlight (formerly WPF/E) Developer Issues...
# 3

And I find a way to produce this bug,

If move this canvas.triggers into other canvas like as root canvas, it will be ok.

Cestlavie at 2007-9-6 > top of Msdn Tech,Silverlight (formerly WPF/E),Silverlight (formerly WPF/E) Developer Issues...
# 4

Have you tried moving your Triggers property before any Children elements inside your Canvas? That might do the trick.

Thanks,

Ed Maia
WPF/E Program Manager

EdMaiaMSFT at 2007-9-6 > top of Msdn Tech,Silverlight (formerly WPF/E),Silverlight (formerly WPF/E) Developer Issues...
# 5
did you find any solution ? because i have exactly the same bug !!!
Wendy at 2007-9-6 > top of Msdn Tech,Silverlight (formerly WPF/E),Silverlight (formerly WPF/E) Developer Issues...
# 6

www.mystart.co.jp

I placed all the Triggers in a Canvas that only contains the Trigger's object.

After do that, It will be ok.

Cestlavie at 2007-9-6 > top of Msdn Tech,Silverlight (formerly WPF/E),Silverlight (formerly WPF/E) Developer Issues...