I am currently doing an application on Windows Phone 8 to create formations game, the user creates a demand each player, this is done dynamically. The problem is that when I do dynamic as follows:
private void Add_Click(object sender, EventArgs e)
{
Grid grilla = new Grid();
Image img = new Image();
Random rnd = new Random();
int leftPos = rnd.Next(0, 300);
int rightPos = rnd.Next(0, 300);
string ruta = "Images/Icons/1387004933_school_events.png";
BitmapImage bm = new BitmapImage(new Uri(@ruta, UriKind.RelativeOrAbsolute));
img.Height = 45;
img.Width = 45;
img.Source = bm;
img.MouseMove += new MouseEventHandler(MouseMoving);
img.Margin = new Thickness(leftPos, rightPos, rightPos, leftPos);
MouseDragElementBehavior mouseDragElementBehavior = new MouseDragElementBehavior();
mouseDragElementBehavior.ConstrainToParentBounds = true;
//Interaction.GetBehaviors(img).Add(mouseDragElementBehavior);
grilla.MouseMove += new MouseEventHandler(MouseMoving);
Interaction.GetBehaviors(grilla).Add(mouseDragElementBehavior);
TextBlock caja = new TextBlock();
caja.Text = "Name Player";
grilla.Children.Add(caja);
grilla.Children.Add(img);
grilla.Width = 300;
grilla.Height = 300;
ContentPanel.Children.Add(grilla);
}
It's dynamically created and added Handler to be Drag & Drop but when added want both image (45x45) as texblock appear together or with self-adjusting, as along as possible and under each other, Actually, the image is very biggest. Help me!
|image|
|Name Player|
In this order