Click here to Skip to main content
15,888,162 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi.
I made an element in WPF and its name is "MyRecElem"
I need to move up the element on the page.
I used below code.
But no luck.
Any kindly help please?

What I have tried:

VB
Private Sub btnStartMoving_Click(sender As Object, e As RoutedEventArgs) Handles btnStartMoving.Click

        'Move up the MyRecElem which is the element I need to move up.
        Dim DAMyRecElem = New DoubleAnimation With {
            .From = 3,
            .To = 150,
            .FillBehavior = FillBehavior.HoldEnd,
            .BeginTime = TimeSpan.FromSeconds(0),
            .Duration = New Duration(TimeSpan.FromSeconds(1)),
            .EasingFunction = New PowerEase With {
                        .EasingMode = EasingMode.EaseOut
                    }}
        Dim storyboardMyRecElem = New Storyboard()
        Storyboard.SetTarget(DAMyRecElem, MyRecElem)
        Storyboard.SetTargetProperty(DAMyRecElem, New PropertyPath(TranslateTransform.YProperty))
        storyboardMyRecElem.Children.Add(DAMyRecElem)
        storyboardMyRecElem.Begin()

End Sub
Posted
Comments
[no name] 8-Dec-23 14:40pm    
Just vary the .Left and / or .Top.

https://stackoverflow.com/questions/14978820/move-a-rectangle-on-a-canvas-in-wpf-from-code-behind

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900