Событие ManipulationCompleted не срабатывает на кнопке

В моем универсальном приложении Windows Phone 8.1 у меня есть ListView с кнопкой в ​​ItemTemplate, и мне нужно видеть, когда срабатывают события ManipulationStarted и ManipulationCompleted этой кнопки. Сейчас ManipulationStarted работает нормально, а ManipulationCompleted нет. Может ли кто-нибудь помочь объяснить, почему?

SnapsPage.xaml

<Grid Grid.Row="0" Background="#88686868">
    <Grid.RowDefinitions>
        <RowDefinition Height="130" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>

    <StackPanel Grid.Row="0" Orientation="Vertical" Margin="20,0,0,0">
        <TextBlock Text="{Binding Path=Manager.Account.Username, FallbackValue='loading...'}" Margin="0,12,0,0" Style="{ThemeResource HeaderTextBlockStyle}"/>
        <TextBlock x:Uid="Snaps" Text="SNAPS" Style="{ThemeResource TitleTextBlockStyle}" Typography.Capitals="SmallCaps"/>
    </StackPanel>

    <ScrollViewer x:Name="ScrollViewer" VerticalScrollBarVisibility="Auto"  HorizontalScrollBarVisibility="Disabled" 
                  Padding="0,0,0,20" Grid.Row="1" HorizontalContentAlignment="Stretch">
        <ListView HorizontalContentAlignment="Stretch" 
                  ItemsSource="{Binding Path=Manager.Account.Snaps}">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <Button x:Name="ButtonSnap" Style="{StaticResource BasicEmptyButtonStyle}"
                            ManipulationStarting="ButtonSnap_OnManipulationStarting"
                            ManipulationCompleted="ButtonSnap_OnManipulationCompleted"
                            ManipulationMode="All"
                            Command="{Binding ElementName=ItemsControl, Path=DataContext.TryDownloadMediaCommand}" 
                            CommandParameter="{Binding}">

                        <!-- Content Here -->

                    </Button>
                </DataTemplate>
            </ListView.ItemTemplate>
            <ListView.ItemsPanel>
                <ItemsPanelTemplate>
                    <VirtualizingStackPanel HorizontalAlignment="Stretch"></VirtualizingStackPanel>
                </ItemsPanelTemplate>
            </ListView.ItemsPanel>
        </ListView>
    </ScrollViewer>
</Grid>

<Grid Grid.Row="0" x:Name="MediaGrid" Background="#FF000000" IsHitTestVisible="False">
    <Image x:Name="MediaImage" IsHitTestVisible="False"/>

    <Grid Width="45" Height="45" Background="#99000000"
          VerticalAlignment="Top" HorizontalAlignment="Right" Margin="25">
        <TextBlock Text="10" VerticalAlignment="Center" HorizontalAlignment="Center" FontFamily="Segoe WP Semibold" FontSize="24" />
    </Grid>
</Grid>

SnapsPage.cs

    private void ButtonSnap_OnManipulationStarting(object sender, ManipulationStartingRoutedEventArgs e)
    {
        Debug.WriteLine("ButtonSnap_OnManipulationStarting");
        var button = sender as Button;
        if (button == null) return;
        var snap = button.DataContext as Snap;
        if (snap == null) return;
        _relevantSnap = snap;

        _isFingerDown = true;
        _scrollYIndex = ScrollViewer.VerticalOffset;
        _holdingTimer.Start();
    }

    private void ButtonSnap_OnManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
    {
        Debug.WriteLine("ButtonSnap_OnManipulationCompleted");
        _isFingerDown = false;

        if (_isMediaOpen)
            DisposeMediaTidily();
    }

person Alexander Forbes-Reed    schedule 27.04.2014    source источник


Ответы (1)


Примечание. Я тестировал приложение XAML для Windows Phone 8.1 (не Silverlight).

Кнопка имеет ManipulationMode системы, которая, согласно в документах означает, что вы не должны получать события манипуляции.

Элемент должен иметь значение ManipulationMode, отличное от None или System, чтобы быть источником события манипуляции.

person Shawn Kendrot    schedule 25.07.2014
comment
Я пойду с этим и отчитаюсь позже. (также не используя Silverlight) - person Alexander Forbes-Reed; 05.08.2014