Search code examples
c#windows-phone-8textblock

How to move the textblock location programmatically


In my WP8, i wanted to move a textblock location from existing place to new place (x,y). I tried using

Canvas.SetTop(text1, y);
Canvas.SetLeft(text1, x);

but it fails to change the textblock location. Is there any bestway to do this?


Solution

  • If you want to move the textbox inside a given grid/canvas u can set the margin programmatically.

     textBlock.Margin = new Thickness(left, top, right, bottom);
    

    just adjust the values based on where/how you want to move it