ScrollViewer 在 Surface 4 上不起作用 - WPF C#

ScrollViewer doesn't work on Surface 4 - WPF C#

我正在用 WPF (C#) 创建一个应用程序。 这是我的问题,当在 surface 4 上进行测试时,使用手写笔时 ScrollViewer 不起作用,即不滚动。 但很明显,如果我用你的手指尝试,手指就会起作用。难不成表面笔应该和windows区别对待?我该如何解决这个小而大的问题? 这是我的代码,它适用于你的手指滚动,表面 4 没有笔。帮助:)

<ScrollViewer x:Name="listPastMeetinsVisibility" Grid.Column="0" Grid.Row="0" Margin="15,36,15,35" Background="GhostWhite" VerticalScrollBarVisibility="Hidden" PanningMode="Both">
          <ItemsControl ItemsSource="{Binding Path=PastMeetingList}">
            <ItemsControl.ItemTemplate>
              <DataTemplate>
                <surface:SurfaceButton Tag="{Binding MID}" Click="Meeting_Click">
                    <Button.Template>
                        <ControlTemplate TargetType="{x:Type Button}">
                            <StackPanel>                        
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="118"></ColumnDefinition>
                                    <ColumnDefinition Width="*"></ColumnDefinition>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="60"/>
                                </Grid.RowDefinitions>
                                <Border Grid.Row="0" Grid.ColumnSpan="2" BorderBrush="#DDD" BorderThickness="0,0,0,1"></Border>
                                <TextBlock Foreground="#565656" FontFamily="{StaticResource Lato Light}" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Left" FontSize="28" Margin="20,5,0,0" Style="{DynamicResource Lato-Semibold}" Text="{Binding PastDayString}"/>
                                <TextBlock Foreground="#565656" FontFamily="{StaticResource Lato Light}" Grid.Row="0" Grid.Column="0" Text="{Binding PastMonthString}" FontSize="12" Margin="8,37,0,0"/>
                                <TextBlock Foreground="#565656" FontFamily="{StaticResource Lato Light}" Grid.Row="0" Grid.Column="0" Text="{Binding StartDate.Year}" FontSize="12" Margin="37,37,0,0"/>
                                <TextBlock Foreground="#565656" FontFamily="{StaticResource Lato Light}" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Left" Width="28" FontSize="12" Height="Auto" Margin="85,12,0,0" Style="{DynamicResource Lato-Semibold}" Text="{Binding PastDayOfWeekString}"/>
                                <TextBlock Foreground="#565656" FontFamily="{StaticResource Lato Light}" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Left" FontSize="14" Margin="75,33,0,0" Height="Auto" Style="{DynamicResource Lato-Semibold}" Text="{Binding PastHourString}"/>
                                <TextBlock Foreground="#565656" FontFamily="{StaticResource Lato Light}" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Left" FontSize="14" Margin="91,33,0,0" Height="Auto" Style="{DynamicResource Lato-Semibold}" Text=":"/>
                                <TextBlock Foreground="#565656" FontFamily="{StaticResource Lato Light}" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Left" FontSize="14" Margin="95,33,0,0" Height="Auto" Style="{DynamicResource Lato-Semibold}" Text="{Binding PastMinuteString}"/>
                                <TextBlock Foreground="#565656" FontFamily="{StaticResource Lato Light}" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Left" Text="{Binding Subject}" FontWeight="Bold" FontSize="14" Margin="20,14,0,0"/>
                                <TextBlock Foreground="#565656" FontFamily="{StaticResource Lato Light}" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Left" Text="{Binding Subject}" FontSize="13" Margin="20,33,0,0"/>
                                <Image Grid.Row="0" Visibility="{Binding Presence, Converter={StaticResource booleanToVisibilityConverter}}" Grid.Column="1" Source="/Resources/Images/icon-presence.png" Margin="0,0,7,0" Width="24" HorizontalAlignment="Right"></Image> 
                            </Grid>
                            </StackPanel>
                                </ControlTemplate>
                            </Button.Template>
                        </surface:SurfaceButton>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
          </ItemsControl>
        </ScrollViewer>

我是这样解决的:

1 - 从 NuGet 下载 Microsoft.Surface : https://www.nuget.org/packages/Microsoft.Surface/

2 - 将程序集添加到 xaml :

xmlns:surface = "http://schemas.microsoft.com/surface/2008"

3 - 将 ScrollViewer 更改为 surface:SurfaceScrollViewer

使用 SurfaceScrollViewer 更新了代码:

<surface:SurfaceScrollViewer x:Name="listPastMeetinsVisibility" Grid.Column="0" Grid.Row="0" Margin="15,36,15,35" Background="GhostWhite" VerticalScrollBarVisibility="Hidden" PanningMode="Both">
          <ItemsControl ItemsSource="{Binding Path=PastMeetingList}">
            <ItemsControl.ItemTemplate>
              <DataTemplate>
                <Button Tag="{Binding MID}" Click="Meeting_Click">
                    <Button.Template>
                        <ControlTemplate TargetType="{x:Type Button}">
                            <StackPanel>                        
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="118"></ColumnDefinition>
                                    <ColumnDefinition Width="*"></ColumnDefinition>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="60"/>
                                </Grid.RowDefinitions>
                                <Border Grid.Row="0" Grid.ColumnSpan="2" BorderBrush="#DDD" BorderThickness="0,0,0,1"></Border>
                                <TextBlock Foreground="#565656" FontFamily="{StaticResource Lato Light}" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Left" FontSize="28" Margin="20,5,0,0" Style="{DynamicResource Lato-Semibold}" Text="{Binding PastDayString}"/>
                                <TextBlock Foreground="#565656" FontFamily="{StaticResource Lato Light}" Grid.Row="0" Grid.Column="0" Text="{Binding PastMonthString}" FontSize="12" Margin="8,37,0,0"/>
                                <TextBlock Foreground="#565656" FontFamily="{StaticResource Lato Light}" Grid.Row="0" Grid.Column="0" Text="{Binding StartDate.Year}" FontSize="12" Margin="37,37,0,0"/>
                                <TextBlock Foreground="#565656" FontFamily="{StaticResource Lato Light}" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Left" Width="28" FontSize="12" Height="Auto" Margin="85,12,0,0" Style="{DynamicResource Lato-Semibold}" Text="{Binding PastDayOfWeekString}"/>
                                <TextBlock Foreground="#565656" FontFamily="{StaticResource Lato Light}" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Left" FontSize="14" Margin="75,33,0,0" Height="Auto" Style="{DynamicResource Lato-Semibold}" Text="{Binding PastHourString}"/>
                                <TextBlock Foreground="#565656" FontFamily="{StaticResource Lato Light}" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Left" FontSize="14" Margin="91,33,0,0" Height="Auto" Style="{DynamicResource Lato-Semibold}" Text=":"/>
                                <TextBlock Foreground="#565656" FontFamily="{StaticResource Lato Light}" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Left" FontSize="14" Margin="95,33,0,0" Height="Auto" Style="{DynamicResource Lato-Semibold}" Text="{Binding PastMinuteString}"/>
                                <TextBlock Foreground="#565656" FontFamily="{StaticResource Lato Light}" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Left" Text="{Binding Subject}" FontWeight="Bold" FontSize="14" Margin="20,14,0,0"/>
                                <TextBlock Foreground="#565656" FontFamily="{StaticResource Lato Light}" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Left" Text="{Binding Subject}" FontSize="13" Margin="20,33,0,0"/>
                                <Image Grid.Row="0" Visibility="{Binding Presence, Converter={StaticResource booleanToVisibilityConverter}}" Grid.Column="1" Source="/Resources/Images/icon-presence.png" Margin="0,0,7,0" Width="24" HorizontalAlignment="Right"></Image> 
                            </Grid>
                            </StackPanel>
                                </ControlTemplate>
                            </Button.Template>
                        </Button>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
          </ItemsControl>
        </surface:SurfaceScrollViewer>

在 Surface scrollviewer 上使用 Stylus 笔:)