1

我有基于 Silverlight 的网络应用程序。我发现 ListBox 在鼠标滚轮滚动时不滚动。我可以通过单击垂直滚动条来滚动。当我使用鼠标滚轮或 2 指滚动时,它不起作用。在这里,在列表框 2 中的鼠标滚轮滚动工作正常,但列表框 1 不起作用。

列表框 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>               

列表框 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>
4

1 回答 1

0

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.

于 2013-09-27T12:25:00.537 回答