My advice would be if you can't get it working with WPF then you'll not get
very far with SL.

 

Also, WPF Unleashed warns about using ActualHeight and ActualWidth as they
are updated every time

the layout process runs which is asynchronous. Don't know if this has
anything to do with what goes on in SL

but thought you might like to know.

 

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Stephen Price
Sent: Thursday, 15 May 2008 12:39 PM
To: listserver@ozsilverlight.com
Subject: [OzSilverlight] ActualWidth

 

Hi guys,

I've come across this issue before with WPF, and have now hit something
similar in Silverlight. I've got a page with a Canvas element on it called
"pageContents" and I'm loading XAML fragments into the contents of the
Canvas. 
That works no problems, but what I'm having issues with is the
pageContents.ActualWidth (and ActualHeight) are not updating. The Canvas
starts off with no content and Width and Height are not set, so default to
Auto. Adding the content automatically sizes the Canvas but the ActualHeight
and ActualWidth are still showing as 0 (zero). 

I've got a snippet of code that tells me if the mouse click was inside the
bounds of the Canvas and I need to know the dimensions of the canvas.
Calling pageContents.Measure(availablesize) doesn't seem to help. Any other
tricks I can use?

protected void Page_MouseLeftButtonDown(object sender, MouseEventArgs e) {
    var contentRect = new
Rect((double)pageContents.GetValue(Canvas.LeftProperty),
(double)pageContents.GetValue(Canvas.TopProperty), pageContents.ActualWidth,
pageContents.ActualHeight);
    var position = e.GetPosition(null);
    if (contentRect.Contains(position)) {
        _lastMousePosition = position;
    }
}

thanks,
Stephen
-------------------------------------------------------------------
OzSilverlight.com - to unsubscribe from this list, send a message back to
the list with 'unsubscribe' as the subject.
Powered by mailenable.com - List managed by www.readify.net 




------------------------------------------------------------------- 
OzSilverlight.com - to unsubscribe from this list, send a message back to the 
list with 'unsubscribe' as the subject.
Powered by mailenable.com - List managed by www.readify.net

Reply via email to