gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 20:38:06 26 4
gpt4 key购买 nike

我正在 WPF (C#) 中创建一个应用程序。这是我的问题,当在 surface 4 上进行测试时,使用手写笔时 ScrollViewer 不起作用,即不滚动。但很明显,如果我用你的手指尝试,手指就会起作用。有没有可能surface pen应该和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 pen :)

关于c# - ScrollViewer 在 Surface 4 上不起作用 - WPF C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35404066/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com