I have a custom UserControl who’s position is bound to parameters in a ViewModel.
<Canvas Name="CursorCanvas">
<ctrl:HandCursor x:Name="RightHandCursor" State="{Binding RightHandState}" Visibility="{Binding IsHandTracking, Converter={StaticResource BoolToVisibilityConverter}}" Canvas.Top="{Binding RightHandY}" Canvas.Left="{Binding RightHandX}" />
</Canvas>
Inside of this control I am performing a HitTest, to determine what is below it. Currently this HitTest is hooked up to a DispatcherTimer ta 1-second intervals. What I’d rather do tell the control to perform the HitTest when it moves on the Canvas, but I am unable to find how to capture the Canvas position updates in the UserControl that is being moved.
How can I capture the Canvas.Top/Left movement updates in the code-behind for the “HandCursor” UserControl defined above?
Many thanks!
You could add a PropertyChangedCallback by overriding the property metadata of the
Canvas.LeftandCanvas.Topattached properties: