Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
date: 13 Mar 2007 18:33:15 -0700,    group: microsoft.public.windows.developer.winfx.avalon        back       


C#: Canvas.Loaded not firing   
I have a Canvas that acts as a background image, let's call this
bgCanvas. I also have another Canvas that contains a TextBlock, let's
call this fgCanvas.

bgCanvas always exists in the scene. An event is raised and as a
result, I create a fgCanvas and add it to bgCanvas's children
collection. Before I add it though, I wire-up fgCanvas.Loaded because
I need to check it's ActualHeight property and you can't do that
before it's calculated. So the idea is, create this canvas, wire up
it's Loaded event, then add it and wait for the event to fire, then
retrieve ActualHeight.

Problem is Loaded never fires. I can visually see fgCanvas on the
screen so Load must have occurred right? But the handler is never
invoked.

I tried LayoutUpdated but that fires way too often and it's a plain
EventHandler with sender always null. I wish there was a
SizeCalculated event or something.. any ideas?
date: 13 Mar 2007 18:33:15 -0700   author:   znelson

Re: C#: Canvas.Loaded not firing   
I worked around this by simplifying and such. I have the bgCanvas and
I subclassed TextBlock which will lay on top. In the subclass I
override OnRenderSizeChanged() and raise a custom event. This gets me
the ActualHeight as soon as it's calculated.

I didn't plan on having to create a custom eventhandler delegate and
event args but unfortunately OnRenderSizeChanged() uses
SizeChangedInfo yet RenderSizeEventHandler uses RenderSizeEventArgs
and the two are not interchangeable. Not only that but when I tried to
instantiate a RenderSizeEventArg I got an error saying there is no
constructor defined.. WHAT?

So in the end I had to roll my own TextBlock subclass, eventargs, and
eventhandler. But it works and that's all that matters right?

I'd still like to know why that Canvas was being rendered on the
screen but Loaded was never firing....
date: 13 Mar 2007 19:11:45 -0700   author:   znelson

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us