Recommended

Skip Navigation LinksHome / Search

Search

 
Results Per Page

Found 2 results for HitTest.
Date between: <not defined> and <not defined>
Search in: News , Articles , Tips , Shows , Showcase , Books

Order by Publish Date   Ascending Title   Rating  

  • 0 comments  /  posted by  Silverlight Show  on  Mar 12, 2009 (more than a year ago)

    lan Blackburn will show you how to make it possible to support dragging over any type of layout.

    A common requirement for a rich UI in a business application is to support dragging and dropping of UI elements.  For this to be successful you will need to be able to detect what elements you are dragging over, and you will need to support dragging over any type of layout (such as a complex grid layout), which is a contrast to many examples out there that only show dragging and dropping in relation to absolute layout with a Canvas.



  • 0 comments  /  posted by  Denislav Savkov  on  Aug 29, 2008 (more than a year ago)

    In Silverlight for hit testing are used the absolute coordinates of the application. In case you want to hit test with coordinates relative to a System.Windows.UIElement you need to get the coordinates of the UIElement relative to the application root (i.e. the absolute coordinates of an element).

    C#

    GeneralTransform generalTransform = uiElement.TransformToVisual( Application.Current.RootVisual);
    Point elementToApplicationRootCoords = generalTransform.Transform( new Point( 0, 0 ) );

    And then add them to the coordinates relative to the element.

    C#

    Rect areaInAbsoluteCoordinates =
        new Rect( areaRelativeLeftCoordinate + elementToApplicationRootCoords.X,
                  areaRelativeTopCoordinate + elementToApplicationRootCoords.Y,
                  areaWidth, areaHeight );
    IEnumerable<UIElement> childrenInArea = uiElement.HitTest(areaInAbsoluteCoordinates );
     
    That's it!

Join the free SilverlightShow webinar 'Silverlight's Power Features: Data Binding in Action' on August 19th 2010, 10:00 am PDT.
In this session Gill Cleeren will make with a complete overview of the data binding features Silverlight 4 has to offer. He will discuss how data binding is the enabler for applying the MVVM pattern and commanding, and will end up reviewing Blend's support for data binding, including the use of design-time data. Read more | Register Now (hide this)