I am not able to use SetTop property Canvas in Silverlight App. Following is the minimal code to reproduce the problem
from System import TimeSpan
from System.Windows import Application, Duration, PropertyPath
from System.Windows.Controls import Canvas, TextBlock
from System.Windows.Media import SolidColorBrush, Colors
from System.Windows.Media.Animation import (
DoubleAnimation, Storyboard, RepeatBehavior
)
root = Canvas()
root.Children.Clear()
root.Resources.Clear()
#root.Background = SolidColorBrush(Colors.Black)
parent = Canvas(Width = 100, Height = 100)
parent.Background = SolidColorBrush(Colors.Black)
parent.SetTop(root, 0)
parent.SetLeft(root, 0)
parent2 = Canvas(Width = 100, Height = 100)
parent2.Background = SolidColorBrush(Colors.Blue)
parent2.SetTop(root, 100)
root.Children.Add(parent)
Application.Current.RootVisual = root
The line "parent2.SetTop(root, 100)" changes the position where parent1 will be displayed.
This behavior is surprising. I am not even adding parent2 as one of the child object still it's affecting the layout.
Can somebody please explain what I am doing wrong?