Search code examples
c#wpfdrag-and-droptouchpixelsense

StackPanel with the Surface API - never any TouchesCapturedWithin


I've been trying to create a visual for dragging and dropping a StackPanel in WPF on the TouchDown event. I've managed to do this already for a SurfaceListBoxItem with no problem but not for a StackPanel. I've narrowed it down to the fact that the TouchesCapturedWithin property for the SurfaceListBoxItem is 1 (as it should be) but is always 0 for a StackPanel (even when looking at this property in the TouchDown event handler for the StackPanel).

    private void stackPanel1_TouchDown(object sender, TouchEventArgs e)
    {
        IEnumerable<TouchDevice> touches = (sender as StackPanel).TouchesCapturedWithin;
    }

I need this IEnumerable further on in the code so I'm assuming that this is why I can't see anything when dragging.

Thanks a lot,

Dan


Solution

  • Sorted it using TouchesOver property instead.