locked
Keep Translate Transform on Page RRS feed

  • Question

  • Hi 

    private void sp_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
            {
                
                Canvas spC = sender as Canvas;
                
                var rtp = spC.GetValue(RenderTransformProperty);
                var tt = rtp as TranslateTransform;
    
                tt.X += e.Delta.Translation.X;
    
                e.Handled = true;
            }
    Above is my code for enabling the user to drag a box around the screen. But I found if the user flings the box fast enough. it goes off screen. Is there a way to make the box stop at the edge of the screen? 
    Sunday, February 2, 2014 11:10 PM

Answers

  • Hi blackasninja,

    Try to reset the position when the Canvas is out of screen.

    You should be able to get the current Canvas position by e.Position and also the Screen Size by http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.window.bounds.aspx, compare them to see if the Canvas is out screen and reset it position.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, February 3, 2014 3:47 AM
    Moderator