ScrollViewer不适用于Surface 4 - WPF C#

时间:2016-02-15 07:53:25

标签: c# wpf scrollviewer mahapps.metro

我正在WPF(C#)中创建一个应用程序。 而这就是我的问题,当表面测试4,使用手写笔ScrollViewer不起作用时,不会滚动。 但很明显,如果我用手指尝试,手指就会起作用。它'可能表面笔应与窗户区别对待吗?我怎样才能解决这个小问题呢? 这是我的代码,它适用于你的手指滚动,表面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 个答案:

答案 0 :(得分: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>

在表面滚动查看器上享受手写笔:)