darthmaule2
Topic Author
Posts: 98
Joined: 23 Oct 2014, 19:54

Touch events not working for me in managed SDK

13 Sep 2019, 17:30

I have a ListView control defined like this:
        <ListView x:Name="CurrentDirectoryListView"
                SelectionMode="Single"
                Style="{StaticResource FileManagerListViewStyle}"
                ItemContainerStyle="{StaticResource FileManagerListViewItemStyle}"                    
                ItemsSource="{Binding CurrentDirectoryContents}"
                TouchDown="OnTouchDown">


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">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ListView}">
                            <ScrollViewer Margin="1" Style="{StaticResource SimpleScrollViewer}" CanContentScroll="True" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Disabled" PanningMode="VerticalOnly" Focusable="false" >
                                <ItemsPresenter >
                                </ItemsPresenter>
                            </ScrollViewer>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
Do I have to turn touch events on somehow? Or, is there something that I'm doing which could be turning them off?

Thanks.
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: Touch events not working for me in managed SDK

16 Sep 2019, 16:45

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.

Who is online

Users browsing this forum: No registered users and 80 guests