Skip to main content

Microsoft Silverlight

Answered Question How to get a control's (i.e. textblock) position in a gridRSS Feed

(0)

pratham78
pratham78

Member

Member

3 points

31 Posts

How to get a control's (i.e. textblock) position in a grid

I have textblocks created dynamically and positioned in a grid.  I added addhandlers to handle events for the textblock.  Is there a way to find out on which row and column my textblock positioned on the grid?

nandkishor.phalke
nandkish...

Member

Member

71 points

49 Posts

Re: How to get a control's (i.e. textblock) position in a grid

Hi,

cau u try for this. 

TextBlock tt= (TextBlock)LayoutRoot.FindName("Test");

var temp = tt.Parent;

use temp for getting position . 

 

duefectu
duefectu

Participant

Participant

788 points

241 Posts

Answered Question

Re: Re: How to get a control's (i.e. textblock) position in a grid

On your click event you can put something like this:

            int grid=Grid.GetColumn((FrameworkElement)sender);
            int column = Grid.GetRow((FrameworkElement)sender);

Un saludo!
Juan Segura

Plase, "Mark as Answer..." if it solve the problem!

pratham78
pratham78

Member

Member

3 points

31 Posts

Re: How to get a control's (i.e. textblock) position in a grid

I tried your solution on a different problem I had and that worked out to be great...

Thanks

pratham78
pratham78

Member

Member

3 points

31 Posts

Re: How to get a control's (i.e. textblock) position in a grid

pratham78:

I tried your solution on a different problem I had and that worked out to be great...

Thanks

 

Sorry that message was for NandKishore

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities