Windows 8商店应用。列表显示。触摸项目滚动和指针*事件

时间:2014-06-06 16:26:23

标签: c# .net windows-8 windows-8.1

我有listView项目:

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <ListView x:Name="_listView" SelectionMode="None" VerticalAlignment="Center" 
                  ScrollViewer.VerticalScrollMode="Disabled"
                  ScrollViewer.HorizontalScrollBarVisibility="Hidden" 
                  ScrollViewer.HorizontalScrollMode="Enabled" IsTapEnabled="False" IsHoldingEnabled="False" IsSwipeEnabled="False">
        <ListView.ItemsPanel>
            <ItemsPanelTemplate>
                <StackPanel Orientation="Horizontal"/>
            </ItemsPanelTemplate>
        </ListView.ItemsPanel>
    </ListView>
</Grid>


public MainPage()
    {
        this.InitializeComponent();
        for (int i = 0; i < 30; i++) 
        {
            Border _border = new Border();
            _border.Width = 400;
            _border.Height = 300;
            _border.Background = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 0, 255, 255));
            _border.PointerPressed += _border_PointerPressed;
            _border.PointerReleased += _border_PointerReleased;
            _border.PointerExited += _border_PointerExited;
            _border.PointerEntered += _border_PointerEntered;
            //_border.ManipulationMode = ManipulationModes.All;
            _listView.Items.Add(_border);
        }
    }

    void _border_PointerEntered(object sender, PointerRoutedEventArgs e)
    {
        Border border = sender as Border;
        border.Background = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 255, 255, 0));
    }

    void _border_PointerExited(object sender, PointerRoutedEventArgs e)
    {
        Border border = sender as Border;
        border.Background = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 0, 255, 255));
    }

    void _border_PointerReleased(object sender, PointerRoutedEventArgs e)
    {
        Border border = sender as Border;
        border.Background = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 0, 255, 255));
    }

    void _border_PointerPressed(object sender, PointerRoutedEventArgs e)
    {
        Border border = sender as Border;
        border.Background = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 255, 255, 0));
    }

当我尝试使用触摸项目时 - PointerExited,PointerReleased,PointerMoved - 未触发。如果我取消注释_border.ManipulationMode = ManipulationModes.All - 事件被触发,但滚动不起作用:(。请告诉我,如果它是pussibele,如何实现触发这些事件并滚动?谢谢。

1 个答案:

答案 0 :(得分:0)

尝试使用ManipulationModes.All|ManipulationModes.System