ivan_b
Topic Author
Posts: 87
Joined: 22 Jul 2015, 12:57

Scroll problem

09 May 2016, 10:09

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.
 
User avatar
ai_enabled
Posts: 221
Joined: 18 Jul 2013, 05:28
Contact:

Re: Scroll problem

09 May 2016, 10:56

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!
AtomicTorch Studio Pte. Ltd. http://atomictorch.com
 
ivan_b
Topic Author
Posts: 87
Joined: 22 Jul 2015, 12:57

Re: Scroll problem

09 May 2016, 12:32

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.
 
User avatar
ai_enabled
Posts: 221
Joined: 18 Jul 2013, 05:28
Contact:

Re: Scroll problem

09 May 2016, 13:00

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!
AtomicTorch Studio Pte. Ltd. http://atomictorch.com
 
ivan_b
Topic Author
Posts: 87
Joined: 22 Jul 2015, 12:57

Re: Scroll problem

09 May 2016, 13:46

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.
 
User avatar
ai_enabled
Posts: 221
Joined: 18 Jul 2013, 05:28
Contact:

Re: Scroll problem

09 May 2016, 14:34

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.
AtomicTorch Studio Pte. Ltd. http://atomictorch.com
 
ivan_b
Topic Author
Posts: 87
Joined: 22 Jul 2015, 12:57

Re: Scroll problem

09 May 2016, 14:37

Thank you, I forgot about that option :)
 
User avatar
ai_enabled
Posts: 221
Joined: 18 Jul 2013, 05:28
Contact:

Re: Scroll problem

09 May 2016, 14:40

I'm glad to help! :-)
AtomicTorch Studio Pte. Ltd. http://atomictorch.com
 
User avatar
sfernandez
Site Admin
Posts: 1911
Joined: 22 Dec 2011, 19:20

Re: Scroll problem

10 May 2016, 19:22

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.

Who is online

Users browsing this forum: No registered users and 2 guests