Question WPF snap to edge


New member
Jun 13, 2014
Programming Experience
Hello everyone,

First of all I want to say, that I'm trying to resolve this problem since few days, and believe me I search lot of pages on google, and really nothing:/. For me it's very hard to resolve, becouse my knowledge about C# is still at beginner. But first of all I just think about small feature that will snap my window to edge of screen (for example, when I move window for some small distance from edge (top or right or etc), window will in magnetic way stick to edge of screen). I dont want to make snap do other windows in my applications, or make top on all top, just "only" make dock, snap, magnet, or whatever, to edge screen. In first moment, I thought, that it will be not so complex, but after I search google, there is really no such solutions in simply way://. Moreover, the only solution which work and it's really fine, I have found (really, this is only code that really work, on all gooooogle:)) - is written in VB.

I tried to rewrite it for C#, but unfortunatell, I'm doing WPF app, that's why there sooo much incosistency that I really cannot fight with this:// 5 days and still nothing:/. I know that I'm asking for much, I know, but I really don't have any solution, how make WPF to work with this.

Only solution like I wrote is here (VB):

A .NET Snap To Screen Form - CodeProject

Can somebody try help me somehow?

Thanks even for read this!;)
not sure if this is what you want the form_move event try this

  private void Form1_Move(object sender, EventArgs e)        {
            this.Top = Screen.PrimaryScreen.Bounds.Top;
            this.Left = Screen.PrimaryScreen.Bounds.Left;

this will weld the form to the screenbounds....

hope this help....


Latest posts

Top Bottom