How to allow manipulations within ListView/GridView Item controls while allowing scroll and cross-slide manipulations on the ListView/GridView?

后端 未结 2 1505
日久生厌
日久生厌 2020-12-20 03:48

Specifically, I have a custom user control that receives manipulation events to scroll a custom DirectX control. This control, and others like it, are items in a GridView. I

2条回答
  •  离开以前
    2020-12-20 04:26

    It can't be done with 8.0 (for 8.1 scroll to EDIT). You would need to implement your own ScrollViewer to use in the GridView template or put a layer on top of the GridView and relay all input calls as I suggested before. Actually, perhaps implementing your own version of ScrollViewer wouldn't be that hard (a Canvas control with one child that calls Canvas.SetLeft on its child item on manipulation events).

    One new idea I have that might work for you is to put another ScrollViewer in front of your DirectX control and use its ViewChanged events as you would use the manipulation events - check this:

    XAML

    
        
            
                
                    
                    
                        
                    
                    
                
                
                
                
                
                
                
            
        
    
    

    Code behind

    using Windows.UI.Xaml.Controls;
    
    namespace App84
    {
        public sealed partial class MainPage : Page
        {
            public MainPage()
            {
                this.InitializeComponent();
            }
    
            private void ScrollViewer_OnViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
            {
                OffsetTextBlock.Text =
                    ManipulationCaptureScrollViewer.VerticalOffset.ToString();
            }
        }
    }
    

    EDIT*

    Also with Windows 8.1 you get ManipulationModes.System which combined with other modes (scale and rotate are not supported though) should allow you to handle manipulations inside of a ScrollViewer. Then you can call CancelDirectManipulations() on the manipulated element once you want its parent ScrollViewers to stop processing manipulations for pan&zoom.

提交回复
热议问题