I have a WPF Form with different types of control like textboxes, textblocks, combobox, buttons etc. I need to add tooltips to each of these controls dynamically using C#, so that they can display the following information:
- X and Y position
- TabIndex.
I do the code as below for each control as below (code for textbox for now):
foreach (Control ctrl in grd.Children)
{
if (ctrl.GetType().ToString() == "System.Controls.TextBox")
{
tbox = ctrl as TextBox;
Point p = Mouse.GetPosition(tbox);
tbox.ToolTip =p.X + " " + p.Y + " \n " + tbox.TabIndex ;
}
}
But this is not working. Any thoughts?