首页 新闻 搜索 专区 学院

多点触摸,不能(触摸)双击,但是鼠标双击一直可以。

1
悬赏园豆:100 [已关闭问题] 关闭于 2011-06-07 12:13

//Window x:Class="ContinuousList.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:l="clr-namespace:ContinuousList"

        Title="MainWindow" Height="350" Width="525" WindowState="Maximized"//
  
    //Grid>
        //Grid.RowDefinitions>
   
            //RowDefinition Height="*" />
        //Grid.RowDefinitions//

        //ListBox Height="300" Width="1920" HorizontalAlignment="Left" Name="MainSurfaceListBox"  ScrollViewer.CanContentScroll="False" ScrollViewer.PanningDeceleration="0.005"
                 ScrollViewer.PanningMode="None" VerticalAlignment="Center" MouseDoubleClick="MainSurfaceListBox_MouseDoubleClick" //

            //ListBox.ItemTemplate//
                //DataTemplate//
                    //Image Source="{Binding}" Margin="10,10" Width="200" Height="200"//
                //DataTemplate //              
            //ListBox.ItemTemplate //         
 
            //ListBox.ItemsPanel//

                //ItemsPanelTemplate//
                    //VirtualizingStackPanel Orientation="Horizontal"//
                //ItemsPanelTemplate//
            //ListBox.ItemsPanel//
           
        //ListBox //
    //Grid//
//Window//
把上面的“//”用“</  >”替换掉 就行啦。要不他总当html显示。
如上面代码,我用listbox绑定图片水平显示。可以水平方向滑动。但是,当我想双击(触摸双击)图片弹出一个窗口,操作选中的图片时,步响应触摸双击。

但是把 ScrollViewer.PanningMode="None"时,可以触摸双击。不过,这个时候,就不支持滑动效果啦。

下面是对应的cs代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ContinuousList
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
              // Query the registry to find out where the sample photos are stored.
                                   string imagesPath = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
          //  string imagesPath =@"C:\Users\yxd\Pictures\dd";

            try
            {
                // Set the ItemsSource property.
                MainSurfaceListBox.ItemsSource =
                    System.IO.Directory.GetFiles(imagesPath, "*.jpg");
            }
            catch (System.IO.DirectoryNotFoundException)
            {
                // Handle exceptions as needed.
            }

        }

 

        //双击弹出一个任意窗口
        private void MainSurfaceListBox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            ImageShow image1 = new ImageShow();
            image1.Show();
        }

      
    }
}

 

这是全部的代码啦。

有兴趣的可以试试。如果在可以滑动的情况下,还可以双击弹出一个窗口。一定告诉我一下。

杨献东的主页 杨献东 | 菜鸟二级 | 园豆:205
提问于:2011-03-01 19:38
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册