|
-
Feb 5th, 2009, 09:14 PM
#1
Thread Starter
Member
[RESOLVED] Moving form at runtime, using code.
What I want is a control that you click and drag to move the form (Window1). This is incredibly easy in regular visual basic, but wpf manages to make it difficult because the GUI is in a separate thread...
I have the code for the click and drag part, but I need to know how to actually move the form, say, 1 pixel to the left at runtime.
What I've figured out so far is that you can make doubleanimations at runtime with:
Code:
Dim anim As New DoubleAnimation
anim.From = 0
anim.To = 360
anim.Duration() = New Duration(New TimeSpan(0, 0, 0, 0, 500))
anim.RepeatBehavior = New RepeatBehavior(4)
and so on...
but I can't figure out how to use this to actually change the window's position.
-
Feb 5th, 2009, 09:50 PM
#2
Thread Starter
Member
Re: Moving form at runtime, using code.
ooh, just found a very, very simple solution.
Code:
Private Sub Form_MouseDown(ByVal sender As Object, ByVal e As Input.MouseEventArgs) Handles Me.MouseDown
DragMove()
End Sub
-
Feb 6th, 2009, 05:54 AM
#3
Re: [RESOLVED] Moving form at runtime, using code.
 Originally Posted by joebobfrank
What I want is a control that you click and drag to move the form (Window1). This is incredibly easy in regular visual basic, but wpf manages to make it difficult because the GUI is in a separate thread...
As far as I am aware, the GUI threading is exactly the same as it is in winforms (or regular visual basic as you call it). The GUI has its own thread any any code you use within the GUI/form runs on that thread, unless you specify that it should run in a background thread. However, that doesnt matter at all because the code you would need to use (which you have found) would run on the same thread as the GUI anyway...
Anyway I guess it doesnt matter if you have got it sorted but your post just confused me a little :P
-
Feb 9th, 2009, 07:44 PM
#4
Thread Starter
Member
Re: [RESOLVED] Moving form at runtime, using code.
Well when I was trying to adjust the position of the window it would error and tell me it was in another thread or something alone those lines...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|