Page 1 of 1

Touch events not working for me in managed SDK

Posted: 13 Sep 2019, 17:30
by darthmaule2
I have a ListView control defined like this:
        <ListView x:Name="CurrentDirectoryListView"
                Style="{StaticResource FileManagerListViewStyle}"
                ItemContainerStyle="{StaticResource FileManagerListViewItemStyle}"                    
                ItemsSource="{Binding CurrentDirectoryContents}"

And connect TouchDown in code-behind like this:
        protected override bool ConnectEvent(object source, string eventName, string handlerName)
            if (eventName == "TouchDown" && handlerName == "OnTouchDown")
                ((ListView)source).TouchDown += OnTouchDown;
                return true;

            return false;

        private void OnTouchDown(object sender, TouchEventArgs args)
            throw new System.NotImplementedException();
TouchDown is connected in ConnectEvent but never fires for me.

This same ListView also has a ScrollViewer but it doesn't pan with touch:
                <Setter Property="Template">
                        <ControlTemplate TargetType="{x:Type ListView}">
                            <ScrollViewer Margin="1" Style="{StaticResource SimpleScrollViewer}" CanContentScroll="True" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Disabled" PanningMode="VerticalOnly" Focusable="false" >
                                <ItemsPresenter >
Do I have to turn touch events on somehow? Or, is there something that I'm doing which could be turning them off?


Re: Touch events not working for me in managed SDK

Posted: 16 Sep 2019, 16:45
by sfernandez
Connecting to TouchDown event in the ListView won't work if you have a ScrollViewer inside because the ScrollViewer will handle the event before it reaches the ListView. You will probably want to connect to PreviewTouchDown event instead.

About touch events not working for the ScrollViewer, which platform are you using? Events are injected into the View by the Display implementation corresponding to each platform, perhaps something is missing yet.