asusralis
Topic Author
Posts: 5
Joined: 30 Jul 2018, 05:03

ListBox won't scroll by dragging on mobile

07 Nov 2018, 20:41

When I drag my finger on the list it just selects whatever item is under it. The wanted behavior is that, instead of selecting, it would scroll the list.
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="1*"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height=".5*"/>
                <RowDefinition Height="1*"/>
            </Grid.RowDefinitions>
            <ListBox Margin="5" ItemsSource="{Binding AvailableCharacters}"
                     SelectedValue="{Binding SelectedAvailableCharacter}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <TextBlock Text="{Binding Name}"
                                       FontSize="50"/>
                        </Grid>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
            ....
      </Grid>
            

Tags:
 
User avatar
sfernandez
Site Admin
Posts: 1344
Joined: 22 Dec 2011, 19:20

Re: ListBox won't scroll by dragging on mobile

09 Nov 2018, 02:49

Hi,

Are you able to reproduce the problem using our samples? could you please try the Control Gallery demo in your device and load the ListBox sample? Is scroll drag working?
In Unity we have a toggle to simulate touch inputs with mouse and I just verified that dragging a ListBox scrolls it fine.

Are you using your own style+template for the ListBox? Because you probably need to set the ScrollViewer.PanningMode to VerticalOnly (or VerticalFirst) to allow touch to drag the scroll.

Regards.
 
asusralis
Topic Author
Posts: 5
Joined: 30 Jul 2018, 05:03

Re: ListBox won't scroll by dragging on mobile

11 Nov 2018, 04:11

Some of the samples work. The scoreboard example doesn't drag, but the control gallery does. No, the ListBox does not use any custom style.
 
User avatar
jsantos
Site Admin
Posts: 2170
Joined: 20 Jan 2012, 17:18
Contact:

Re: ListBox won't scroll by dragging on mobile

13 Nov 2018, 23:01

Are you setting the PanningMode property to VerticalOnly as explained in the Touch tutorial ?
 
asusralis
Topic Author
Posts: 5
Joined: 30 Jul 2018, 05:03

Re: ListBox won't scroll by dragging on mobile

14 Nov 2018, 02:25

Is that required? I looked at some of the examples, like QuestLog, and I don't see their ListBox have any of those properties assigned. I set them and they didn't change anything.
 
User avatar
sfernandez
Site Admin
Posts: 1344
Joined: 22 Dec 2011, 19:20

Re: ListBox won't scroll by dragging on mobile

14 Nov 2018, 19:12

The Scoreboard sample is using a ScrollViewer (line 226) around the ItemsControl, and that scroll viewer doesn't have the PanningMode set. To enable touch scrolling there you can add PanningMode="VerticalOnly" and it will work.

ListBox and ListView default templates already include its own ScrollViewer with the property PanningMode set to VerticalFirst, so you don't need to explicitly set it in those cases.
 
User avatar
jsantos
Site Admin
Posts: 2170
Joined: 20 Jan 2012, 17:18
Contact:

Re: ListBox won't scroll by dragging on mobile

14 Nov 2018, 23:03

Could you paste here a minimal XAML for testing in XamlPlayer reproducing your issue?

By the way, I tried contacting you in private, you should change your username to avoid exposing your email.
 
asusralis
Topic Author
Posts: 5
Joined: 30 Jul 2018, 05:03

Re: ListBox won't scroll by dragging on mobile

Yesterday, 19:39

A simple listbox in a grid has it happen. The only thing that is different is that I'm applying a scale to my root view.
public partial class RootPageView : UserControl
    {
        public RootPageView()
        {
            this.InitializeComponent();

            this.SizeChanged += this.WindowSizeChangedEventHandler;
        }
#if NOESIS
        void InitializeComponent()
        {
            Noesis.GUI.LoadComponent(this, "Assets/Project/Source/Views/Pages/RootPageView.xaml");
        }
#endif

        private void WindowSizeChangedEventHandler(object sender, SizeChangedEventArgs e)
        {
            const float referenceWidth = 600,
                         referenceHeight = 1200;

            double width = this.ActualWidth,
                   height = this.ActualHeight;

            var scale = Math.Min(width / referenceWidth,
                                 height / referenceHeight);

            Grid control = (Grid)FindName("Root");

            ScaleTransform scaleTransform = (ScaleTransform)control.LayoutTransform;

            scaleTransform.ScaleX = scaleTransform.ScaleY = (float)scale;
        }
    }
<Grid Name="Root">
        <Grid.LayoutTransform>
            <ScaleTransform/>
        </Grid.LayoutTransform>
Besides that, a simple ListBox like this does not allow me to touch scroll (with emulate touch enabled)
<ListBox ItemsSource="{Binding Game.Player.Characters}" Height="200"
             SelectedValue="{Binding SelectedCharacter}"
             ScrollViewer.PanningMode="VerticalOnly">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <TextBlock Text="{Binding Name}" FontSize="50"/>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>

Who is online

Users browsing this forum: Google [Bot] and 4 guests