Bug 324964 (MONO82295) - Canvas.Top and Canvas.Left not obeyed
Summary: Canvas.Top and Canvas.Left not obeyed
Status: RESOLVED WORKSFORME
Alias: MONO82295
Product: Moonlight
Classification: Mono
Component: engine (show other bugs)
Version: 1.0.0
Hardware: Other Other
: P3 - Medium : Enhancement
Target Milestone: ---
Assignee: Mono Bugs
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-08-02 21:35 UTC by Alan McGovern
Modified: 2007-11-13 13:32 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 20:46:42 UTC


---- Reported by alan.mcgovern@gmail.com 2007-08-02 14:35:11 MST ----

When i add an instance of this class to my canvas, it always draws from 0,0
as opposed to Canvas.Top and Canvas.Left. I assume it shouldn't do this

    public class SelectionRectangle : Control
    {
		private Rectangle rect;
		
        public SelectionRectangle()
            :base()
        {
            // Notice i just instantiate a rectangle.
            // The 'SelectionRectangle' that i instantiate is then
            // added to a canvas
            InitializeFromXaml("<Rectangle Name=\"Rect\" />");
            rect = (Rectangle)FindName("Rect");
            rect.Opacity = 0.33;
            rect.Fill = new SolidColorBrush(Colors.Blue);
            rect.Stroke = new SolidColorBrush(Colors.Green);
            rect.StrokeDashArray = new double[] {5, 5 };
            rect.StrokeThickness = 2;
            SetValue<int>(ZIndexProperty, int.MaxValue);
        }
		
		public override object GetValue (DependencyProperty property)
		{
			return rect.GetValue(property);
		}
		
		public override void SetValue<T> (DependencyProperty property, T obj)
		{
			rect.SetValue<T>(property, obj);
		}

    }


Unknown operating system unknown. Setting to default OS "Other".

Comment 1 Sebastien Pouliot 2007-11-13 13:32:57 UTC
The supplied code doesn't run on Silverlight 1.1. This fragment:

	InitializeFromXaml("<Rectangle Name=\"Rect\" />");
	rect = (Rectangle)FindName("Rect");

always results in a null rect (throwing a NullReferenceException at the next line). Changing the lines for:

	rect = (Rectangle) InitializeFromXaml("<Rectangle Name=\"Rect\" />");

does return a Rectangle instance.

Anyway setring Canvas.Left and/or Canvas.Top works in both Moonlight and Silverlight.