2016-02-15 1 views
2

Я создаю приложение в WPF (C#). И вот моя проблема, когда тест на поверхности 4 с помощью стилуса ScrollViewer не работает, что не прокручивается. Но ясно, что если я попытаюсь пальцем, палец будет работать. Возможно, поверхностное перо должно обрабатываться иначе, чем окна? как я могу исправить эту небольшую, но огромную проблему? Вот мой код, он работает с вашим прокруткой пальца, с поверхностью 4 нет ручки. Помощь :)ScrollViewer не работает на Surface 4 - WPF C#

<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> 

ответ

4

Я решил таким образом:

1 - скачать с NuGet Microsoft.Surface: https://www.nuget.org/packages/Microsoft.Surface/

2 - добавить сборку в XAML:

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

3 - изменить ScrollViewer с поверхности: 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> 

Наслаждайтесь Стилус на поверхности ScrollViewer :)

Смежные вопросы