I have a Windows phone 8.0 project that has an image. When the user taps on the image, I have to get the position of the tap and add a text box to this location (above image).
For now, I use the following code, but I always get a wrong position
MessageBox.Show("vao day");
var mp = GetMousePoint(e);
MessageBox.Show("x=" + mp.X + "_" + "y=" + mp.Y);
//x: 258; y:97
double top= 0; double right = 0; double bottom =0; double left=0;
top = e.GetPosition(OrginalImage).Y; //(double)mp.Y - 50;
left = e.GetPosition(OrginalImage).X; //(double)mp.X - 50;
MessageBox.Show("x=" + left.ToString() + "_" + "y=" + top.ToString());
//add textbox to this position
TextBox newtext = new TextBox();
newtext.Text = "truongpm";
newtext.Margin = new Thickness(left, top, right, bottom);
newtext.Width = 124;
newtext.Height = 68;
//button.VerticalAlignment = 234;
//Add contentpanel to your page if there's not one already.
ContentPanel.Children.Add(newtext);
newtext.Visibility = System.Windows.Visibility.Visible;
Can anybody help me please! Thanks
Aucun commentaire:
Enregistrer un commentaire