Page 1 of 1

Scroll problem

Posted: 09 May 2016, 10:09
by ivan_b
Hi

I was trying to implement a horizntal scrolling inside a listbox and I have managed to do that but the problem is that it only scrolls partially, that is, it can be scrolled only by 1 element. I think the problem is with the virtualization. This is the code
ScrollViewer sv = sender as ScrollViewer;
sv.ScrollToHorizontalOffset (args.Delta);
args.Handled = true;
Is there any workaorund for this?

I also have this problem in a listbox when I use arrow keys to navigate betwen items.

Re: Scroll problem

Posted: 09 May 2016, 10:56
by ai_enabled
Hello!

If you need smooth scrolling (pixel-precise), you need to add this attached property to the listbox:
VirtualizingStackPanel.ScrollUnit="Pixel"
So your XAML will look like this:
<ListBox ItemsSource="{Binding ItemsCollection}"
        VirtualizingStackPanel.ScrollUnit="Pixel" />
(see a good tutorial there http://www.jonathanantoine.com/2011/10/ ... zingpanel/ )

Regards!

Re: Scroll problem

Posted: 09 May 2016, 12:32
by ivan_b
Thank you for the tip but this is not the problem, my post was a little misleading .
The problem is that for implementig a horizontall scroll I am using a stack panel and then in the code behind I set the scroll position.
The problem is that in the list should be 8 items but are dysplayed only 5, 4 are visible at the beginning and I can scroll by 1 item to the right.
I hope it is a bit more clear what the problem is.

Re: Scroll problem

Posted: 09 May 2016, 13:00
by ai_enabled
I see. Since v1.2.6 NoesisGUI using virtualization by default for ListBox control. You could disable it (for the listbox control) and see if that resolves the problem:
VirtualizingStackPanel.IsVirtualizing="False"
If it doesn't help, might you post a sample of your XAML please? Just to demonstrate the issue you have, so we (and NoesisGUI guys) could try it with Kaxaml or Visual Studio and see what could be done to resolve the issue.

Regards!

Re: Scroll problem

Posted: 09 May 2016, 13:46
by ivan_b
Hi,

The problem is there even when virtualization is disabled.
This is the xaml code
        <ListBox x:Name="ArticleListBox" Padding="10,0,10,0" 
          ItemsSource="{Binding Articles}" 
          SelectedItem="{Binding SelectedArticle}"
          ScrollViewer.VerticalScrollBarVisibility="Disabled" 
          ScrollViewer.HorizontalScrollBarVisibility="Hidden"
          ScrollViewer.PanningMode="HorizontalOnly"
          VirtualizingStackPanel.Orientation="Horizontal"
          VirtualizingStackPanel.IsVirtualizing="True">
          <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
              <StackPanel Orientation="Horizontal"/>
            </ItemsPanelTemplate>
          </ListBox.ItemsPanel>
          <ListBox.ItemTemplate>
            <DataTemplate>
              <Grid Width="220" Height="110">
                <cv:ImagePreview ImageUrl="{Binding ThumbnailUrl}"/>
              </Grid>
            </DataTemplate>
          </ListBox.ItemTemplate>
        </ListBox
I also have replaced the StackPanel with VirtualizingStackPanel but the problem is the same.
If I remove the ItemsPanelTemplate property I can't set the orientation of the VirtualizingStackPanel it is always vertical.

Re: Scroll problem

Posted: 09 May 2016, 14:34
by ai_enabled
I suppose you will have only a few elements in this listbox, so virtualization is not required.
Maybe you could simply place the listbox control inside a ScrollViewer with horizontal-only scrolling? It will resolve the issue completely.

Re: Scroll problem

Posted: 09 May 2016, 14:37
by ivan_b
Thank you, I forgot about that option :)

Re: Scroll problem

Posted: 09 May 2016, 14:40
by ai_enabled
I'm glad to help! :-)

Re: Scroll problem

Posted: 10 May 2016, 19:22
by sfernandez
Hi Ivan,

Could you please post your xaml with the ListBox and its template, and the events and code behind you used to scroll. I want to verify that nothing is wrong in our side.

I tried with a ListBox using a horizontal StackPanel as items host and it worked as expected.

Thanks.