Probably the best way to do this is by changing the anchors. Anchors are in relative space to the objects parent. So, if you make sure that the parent of the window is as big as the screen you can calculate the desired anchor position like this:
float x = Input.mousePosition.x / Screen.width;
float y = Input.mousePosition.y / Screen.height;
Depending on the corner you are dragging, you have to assign x to anchorMin.x or anchorMax.x, and y to anchorMin.y or anchorMax.y.
Note that your pixel positions / sizes (anchoredPosition and sizeDelta) should be zero.