I created (using c#) a grid with border & the parent layout is another grid. When I try to rezise dynamically, it doesn't give the expected behaviour. I keep the start position (left-top) of border (with grid) fixed & only the right-bottom point is dragged to resize. In the Mouse move event, the width & height are changed depending on the current position. 1) But it always change the start point (left-top) when changing the width & height ? 2) When border get resized the child (grid) doesn't change its dimensions accordingly ? I cann't find any stretching method. But if border is moved, then the child grid moves with it.
Point offsetParent;
.....
private void MouseMoveEvent(object sender, MouseEventArgs e)
{
if (bIsMouseDown)
{
ResizeControl(e);
offsetParent = e.GetPosition(parentGrid); //reset offset to current
}
}
private void ResizeControl(MouseEventArgs e)
{
// get current point
Point CurPosParent = e.GetPosition(parentGrid);
// current & new position difference
Point diff = new Point(CurPosParent.X - offsetParent.X, CurPosParent.Y - offsetParent.Y);
// keep start point (left-top position) of border fixed
// adjust only width & height of border
border1.Width += diff.X; //changes start point (left-top position) ????
border1.Height += diff.Y;
}
VerticalAlignment
andHorizontalAlignment
properties of the border? From my understanding of your description, they should be set toTop
andLeft
respectively – Paul Roberts