Hi Mark, many thanks you for your answer. My question was not enought clear so I attached a simplified version of my App, showing the Custom User Control with its three user defined Properties which I don't know how to Set in the MainPage animation (see below the three wrong statemenets in italic).
How can I reference a User defined Property of a Custom user control? Is that possible? Is my approach wrong? I'm very new in Silverlight.
Thanks
bruno
Custom User Control Xaml
<usercontrol x:class="Coach2D_SL.UC1" xmlns:x="#unknown">
Xmlns … >
<stackpanel x:name="Sp" background="Transparent" margin="100,100,0,0">
<border name="Border1" background="transparent" borderbrush="transparent" borderthickness="2" x:uid="mbi">
<grid>
Width="56" Height="56" />
</grid>
</border>
</stackpanel>
</usercontrol>
CodeBehind
Partial Public Class UC1
Inherits UserControl
Public WriteOnly Property Position As Integer()
Set(value As Integer())
Sp.Margin = New Thickness(value(0) - image1.Width / 2, value(1) - image1.Height / 2, 0, 0)
End Set
End Property
Public WriteOnly Property RotationAngle As Double
Set(value As Double)
Rotate.Angle = value
image1.RenderTransform = Rotate
End Set
End Property
End Class
MainPage.xaml
. . .
xmlns:uc1="clr-namespace:SilverlightApplication1"
. . .
CodeBehind
Imports SilverlightApplication1.UC1
Partial Public Class MainPage
Inherits UserControl
Dim Uc1 As New UC1
Private Sub Canvas1_Loaded(sender As Object, e As System.Windows.RoutedEventArgs) Handles Canvas1.Loaded
Uc1.Position = {70, 150}
Canvas1.Children.Add(Uc1)
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
' Prepare animation
Actpts_X = New DoubleCollection
Actpts_Y = New DoubleCollection
ActAng = New DoubleCollection
'
Dim Anim_X As New DoubleAnimationUsingKeyFrames
Dim Anim_Y As New DoubleAnimationUsingKeyFrames
Dim AnimAng As New DoubleAnimationUsingKeyFrames
'
Dim d As New Duration(TimeSpan.FromSeconds(T))
Anim_X.Duration = d
Anim_Y.Duration = d
AnimAng.Duration = d
' Create Frames
For i = 0 To PolyLine1.Points.Count - 1
Actpts_X.Add(PolyLine1.Points(i).X - Canvas1.Margin.Left)
Actpts_Y.Add(PolyLine1.Points(i).Y - Canvas1.Margin.Top)
Anim_X.KeyFrames.Add(New DiscreteDoubleKeyFrame() With { _
.Value = PolyLine1.Points(i).X, _
.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(i / speed)) _
})
Anim_Y.KeyFrames.Add(New DiscreteDoubleKeyFrame() With { _
.Value = PolyLine1.Points(i).Y, _
.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(i / speed)) _
})
AnimAng.KeyFrames.Add(New DiscreteDoubleKeyFrame() With { _
.Value = RotAng(i), _
.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(i / speed)) _
})
Next
Dim SB As New Storyboard
Canvas1.Resources.Add("unique_id", SB)
SB.Duration = d
SB.Children.Add(Anim_X)
SB.Children.Add(Anim_Y)
SB.Children.Add(AnimAng)
'
Storyboard.SetTargetProperty(Anim_X, New PropertyPath("(Uc1.X)"))
Storyboard.SetTargetProperty(Anim_Y, New PropertyPath("(Uc1.Y)"))
Storyboard.SetTargetProperty(AnimAng, New PropertyPath("(Uc1.Angle)"))
'
Storyboard.SetTarget(Anim_X, Uc2)
Storyboard.SetTarget(Anim_Y, Uc2)
Storyboard.SetTarget(AnimAng, Uc2)
'
SB.Begin()
End Sub