locked
hover over button RRS feed

  • Question

  • Hi, 

    So far I have code that will start drawing a line when u do your first click until u release it.(which works fine)

    What I would like to do next is to, detect for each button while drawing the line if the line is going over the buttons

    Private Sub MainPage_PointerMoved(sender As Object, e As PointerRoutedEventArgs) Handles Me.PointerMoved
    
    
    
      For Each c As Button In g1.Children.OfType(Of Button)()
    
    'I think the code shud go in here
    
            Next
    
    
        End Sub

    But i'm not sure what will be the method to that? Any suggesstion?

    Thank You


    • Edited by Me Man Friday, December 20, 2013 4:29 PM
    Friday, December 20, 2013 4:28 PM

All replies

  • You can get the Button's location from the VisualTreeHelper. Turning it the other way around, you can get the control at a given point with the same class. Either way, once you know the location of the two objects you can do the math to see if they intersect.

    Friday, December 20, 2013 4:48 PM
    Moderator
  • ok, so i'm not really sure how to use the VisualTreeHelper, but i tried to get the location of my buttons using the following code, but it's only giving out the top left corner position only, how can i get the rest?

     For Each c As Button In g1.Children.OfType(Of Button)()
                Dim gt As GeneralTransform = c.TransformToVisual(Nothing)
                Dim p As Point = gt.TransformPoint(New Point(0, 0))
                x111.Text += c.Name & " : " & p.ToString & Environment.NewLine
    
    
            Next

    Thank You

    Saturday, December 21, 2013 1:13 AM