WPF: Dynamically position label in grid

  • Thread starter Thread starter moondaddy
  • Start date Start date
M

moondaddy

I have a window which has textboxes in it and when each textbox get the
focus, I need to position a small label directly under the textbox and right
aligned so the right side of the label and the right side of the textbox are
inline. I could do this in a canvas but I have no idea how to do it in a
grid.



Any good ideas?



This is how I did it in the canvas:



Canvas.SetTop(lblTextLength, Canvas.GetTop(ctl) + ctl.Height +
_textLengthCounterTopOffset);



Canvas.SetLeft(lblTextLength, Canvas.GetLeft(ctl) + ctl.Width +
_textLengthCounterLeftOffset);



lblTextLength.Visibility = Visibility.Visible;





Thanks.
 
Back
Top