Silverlight ListBox不会在Mac上滚动鼠标滚轮移动

时间:2013-09-27 11:32:54

标签: macos silverlight listbox scrollviewer mousewheel

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

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>               

列表框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 个答案:

答案 0 :(得分:0)

很抱歉成为坏消息的承担者:

  

Macintosh的一些当前鼠标设备具有物理或虚拟   鼠标滚轮。但是,Silverlight使用的程序访问层   Macintosh不支持转发鼠标滚轮事件   Silverlight在浏览器托管的情况下。你可以处理   来自Macintosh平台客户端的Silverlight MouseWheel事件,如果是   Silverlight应用程序在浏览器外运行。否则,考虑一下   在HTML DOM处理Macintosh平台的鼠标滚轮事件   水平;有关更多信息,请参阅平台依赖性。

来自MSDN Silverlight Differences on Windows and Macintosh

好消息是,您可以通过JavaScript在HTML页面中收听鼠标滚轮事件,并通过其JavaScript interop API将这些事件传递给Silverlight。另外一个坏消息是我不知道如何让它自动连接到应用程序中的GUI元素,让它们自动正常工作(比如在你的情况下滚动列表框)。据我所知,你必须手动收听它,拿起用户用鼠标悬停在哪个对象上,然后以编程方式滚动GUI组件。