1
votes

I have Silverlight based web app where. I found the ListBox doesn't scroll on mouse wheel scroll. I am able to scroll by clicking vertical scroll bar. When I use mouse wheel or 2 finger scroll it doesn't work. Here in Mouse Wheel scroll in List box 2 is working fine but ListBox 1 it does not work.

ListBox 1

<Border CornerRadius="6,6,0,0" Grid.Row="1" Margin="2,5,2,0" BorderThickness="1,1,1,0" BorderBrush="#FFC4C4C4">
<Grid>
      <ListBox x:Name="filterListBox" Grid.Row="0" Grid.Column="1" Background="Transparent" SelectedIndex="{Binding SelectedFilterIndex, Mode=TwoWay}"  SelectedItem="{Binding SelectedFilterItem, Mode=TwoWay}" SelectionChanged="ListBox_SelectionChanged"  BorderThickness="0" VerticalAlignment="Center" Margin="5,3" ItemContainerStyle="{StaticResource FilterListBoxItemStyle}">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="SelectionChanged">
                            <ei:CallMethodAction TargetObject="{Binding}" MethodName="FilterSelectionChanged"/>
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                    <ListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel Orientation="Horizontal"/>
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>
                    <ListBoxItem Padding="7,2" VerticalContentAlignment="Center" Tag="Popular" Visibility="{Binding Path=IsPopularChannelTab, Mode=TwoWay, Converter={StaticResource BoolToVisibilityConverter}}">
                            <TextBlock Text="{Binding Path=PopularChannelsText, Source={StaticResource PageStrings}}" FontSize="13" FontWeight="SemiBold" FontFamily="Arial" VerticalAlignment="Center" />
                        </ListBoxItem>
                    <ListBoxItem  IsEnabled="False" VerticalContentAlignment="Center" Visibility="{Binding Path=IsPopularChannelTab, Mode=TwoWay, Converter={StaticResource BoolToVisibilityConverter}}">
                            <StackPanel Orientation="Horizontal">
                                <Border BorderBrush="#FFBDBDBD" BorderThickness="0,2,2,2" HorizontalAlignment="Center" VerticalAlignment="Center" Height="20"/>
                                <Border BorderBrush="#FFF8F8F8" BorderThickness="0,2,2,2" HorizontalAlignment="Center" VerticalAlignment="Center" Height="20"/>
                            </StackPanel>
                        </ListBoxItem>
                    <ListBoxItem Padding="7,2" VerticalContentAlignment="Center" Tag="All">
                        <TextBlock Text="{Binding Path=AllChannelsText, Source={StaticResource PageStrings}}" FontSize="12" FontWeight="SemiBold" FontFamily="Arial" VerticalAlignment="Center"/>
                    </ListBoxItem>
                    <ListBoxItem  IsEnabled="False" VerticalContentAlignment="Center">
                        <StackPanel Orientation="Horizontal">
                            <Border BorderBrush="#FFBDBDBD" BorderThickness="0,2,2,2" HorizontalAlignment="Center" VerticalAlignment="Center"  Height="20"/>
                            <Border BorderBrush="#FFF8F8F8" BorderThickness="0,2,2,2" HorizontalAlignment="Center" VerticalAlignment="Center" Height="20"/>
                        </StackPanel>
                    </ListBoxItem>
                    <ListBoxItem Padding="7,2" VerticalContentAlignment="Center" Tag="Favorites">
                        <TextBlock Text="{Binding Path=FavoritesText, Source={StaticResource PageStrings}}" FontSize="13" FontWeight="SemiBold" FontFamily="Arial" VerticalAlignment="Center"/>
                    </ListBoxItem>

                </ListBox>
</Grid>
</Border>               

ListBox 2

<Grid Visibility="{Binding Path=IsHavingProvider, Converter={StaticResource BoolToVisibilityConverter}}" Margin="0,20,0,0" Grid.Row="4">
                <Grid.RowDefinitions>
                    <RowDefinition Height="18"/>
                    <RowDefinition Height="auto"/>
                </Grid.RowDefinitions>

                <core:MagicTextBlock Grid.Row="0" TextBlockStyle="{StaticResource TextBlock_Style}" Text="{Binding Path=Activity, Source={StaticResource PageStrings}}" />

                <ListBox Margin="0,10,0,0" Grid.Row="1"  x:Name="Provider" Width="480" Height="195" HorizontalAlignment="Left"  ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                    ItemsSource="{Binding Providers,Mode=TwoWay}"
                    SelectedItem="{Binding SelectedProvider,Mode=TwoWay}"
                    ItemContainerStyle="{StaticResource Table_ListBoxItem_Style}"
                    DisplayMemberPath="name">
                </ListBox>
            </Grid>
1

1 Answers

0
votes

Sorry to be the bearer of bad news:

Some current mouse devices for Macintosh have a physical or virtual mouse wheel. However, the program access layer used by Silverlight on Macintosh does not support forwarding the mousewheel event to Silverlight in a browser-hosted situation. You can handle the Silverlight MouseWheel event from a Macintosh platform client, if the Silverlight application is running out-of-browser. Otherwise, consider handling mousewheel events for Macintosh platform at the HTML DOM level; for more information, see Platform Dependencies.

From the MSDN Silverlight Differences on Windows and Macintosh.

The good news is you can listen to the mousewheel events in the HTML page via JavaScript and pass those events into Silverlight via its JavaScript interop API. The additional bad news is I don't know of a way to have it automatically wire into the GUI elements in your application to have them automatically just work (like scrolling list boxes in your case). As far as I know, you'd have to manually listen to it, pick up on which object the user is hovering over with their mouse, and programmatically scroll the GUI component.