我在平板电脑华硕ME400 Intel Atom Z2760上运行我的桌面应用程序WPF.所有工作都正常,但是当我使用scrollviewer时,用手指在滚动结束时用手指滚动移动(简化平移模式horizontalOnly),窗口移动,你会看到任务栏片刻.如果我用手指滚动,直到在滚动条中建立后才会看到效果.
我怎么能避免这个窗口运动?当我在滚动条的末尾滚动时,如何锁定窗口并且不允许移动?
我正在开发一个WPF触摸应用程序.我有一个包含按钮的滚动查看器.我想触摸拖动按钮时滚动显示,并在点击时调用按钮的命令.以下是一些入门代码:
<Window x:Class="wpf_Button_Scroll.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:wpf_Button_Scroll"
Title="MainWindow" Height="350" Width="200">
<Window.DataContext>
<my:MyViewModel />
</Window.DataContext>
<Grid>
<ScrollViewer>
<ListView ItemsSource="{Binding MyData}" HorizontalAlignment="Stretch">
<ListView.ItemTemplate>
<DataTemplate>
<Button Content="{Binding}"
Command="{Binding DataContext.MyCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}"
CommandParameter="{Binding}"
Margin="5 2" Width="150" Height="50"
FontSize="30" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ScrollViewer>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
和视图模型:
namespace wpf_Button_Scroll
{
class MyViewModel
{
public MyViewModel()
{
MyCommand = new ICommandImplementation();
}
public string[] MyData
{
get
{
return new string[]{
"one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten",
"eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", …Run Code Online (Sandbox Code Playgroud)