locked
Scrollbar in Listbox does not scroll RRS feed

  • Question

  • Dear All,

    I have a scrollbar on my form and when therer are several Items in the listbox the scrollbar appears. But the mouse scroll does not work. I have to click on the bar and pull it down manually.

    Anyone any suggestions?

    Best,

    Jeppen

    Twitter: @DoSTHGreat

    Wednesday, October 12, 2011 5:52 AM

Answers

  • Try handling the mousewheel manually

    void PojectsCoverFlow_MouseWheel(object sender, MouseWheelEventArgs e)
            {
                int i = -(e.Delta / 120);
                int index = flowControl.SelectedIndex + i;
                if (index < 0)
                    flowControl.First();
                else if (index > flowControl.Items.Count - 1)
                    flowControl.Last();
                else
                    flowControl.SelectedIndex = index;
            }

     

    Wednesday, October 12, 2011 6:13 AM
  • Hi Jeppen

    You can add a Mouse Wheel Scroll Behavior to your ListBox.

    You can see the bahavior in action and download sample at this link.
    http://gallery.expression.microsoft.com/MouseWheelScroll 

    This behavior can be added easily and implements scroll using the mouse wheel on ScrollViewers or on controls that have a ScrollViewer in its template (ComboBox, ListBox, etc...)

    <ListBox Width="180" Height="160" VerticalAlignment="Top" HorizontalAlignment="Left" ToolTipService.ToolTip="ListBox">
                <i:Interaction.Behaviors>
                    <behaviors:MouseWheelScrollBehavior /><-------
                </i:Interaction.Behaviors>
    
                <ListBoxItem Content="Item 1" />
                <ListBoxItem Content="Item 2" />
                <ListBoxItem Content="Item 3" />
                <ListBoxItem Content="Item 4" />
                <ListBoxItem Content="Item 5" />
                <ListBoxItem Content="Item 6" />
                <ListBoxItem Content="Item 7" />
                <ListBoxItem Content="Item 8" />
                <ListBoxItem Content="Item 9" />
                <ListBoxItem Content="Item 10" />
    	    .....
                <ListBoxItem Content="Item 100" />
    </ListBox>



    If this answers your question, please Mark as an answer. Thank you.

     

    Wednesday, October 12, 2011 9:50 PM

All replies

  • Try handling the mousewheel manually

    void PojectsCoverFlow_MouseWheel(object sender, MouseWheelEventArgs e)
            {
                int i = -(e.Delta / 120);
                int index = flowControl.SelectedIndex + i;
                if (index < 0)
                    flowControl.First();
                else if (index > flowControl.Items.Count - 1)
                    flowControl.Last();
                else
                    flowControl.SelectedIndex = index;
            }

     

    Wednesday, October 12, 2011 6:13 AM
  • Hi Jeppen

    You can add a Mouse Wheel Scroll Behavior to your ListBox.

    You can see the bahavior in action and download sample at this link.
    http://gallery.expression.microsoft.com/MouseWheelScroll 

    This behavior can be added easily and implements scroll using the mouse wheel on ScrollViewers or on controls that have a ScrollViewer in its template (ComboBox, ListBox, etc...)

    <ListBox Width="180" Height="160" VerticalAlignment="Top" HorizontalAlignment="Left" ToolTipService.ToolTip="ListBox">
                <i:Interaction.Behaviors>
                    <behaviors:MouseWheelScrollBehavior /><-------
                </i:Interaction.Behaviors>
    
                <ListBoxItem Content="Item 1" />
                <ListBoxItem Content="Item 2" />
                <ListBoxItem Content="Item 3" />
                <ListBoxItem Content="Item 4" />
                <ListBoxItem Content="Item 5" />
                <ListBoxItem Content="Item 6" />
                <ListBoxItem Content="Item 7" />
                <ListBoxItem Content="Item 8" />
                <ListBoxItem Content="Item 9" />
                <ListBoxItem Content="Item 10" />
    	    .....
                <ListBoxItem Content="Item 100" />
    </ListBox>



    If this answers your question, please Mark as an answer. Thank you.

     

    Wednesday, October 12, 2011 9:50 PM