LongListMultiSelector blocks gesture events for selected items

In the following XAML, when LongListMultiSelector

<< 20> is selected, it TextBlock

stops receiving the Tap

event (and any other gesture events), but instead becomes unselected when I click it again. How can I change this behavior so that it TextBlock

always responds Tap

regardless of its choice state?

<toolkit:LongListMultiSelector ItemsSource="{Binding Items}">
    <toolkit:LongListMultiSelector.ItemTemplate>
        <DataTemplate>
            <!-- When TextBlock is selected, Debug_WriteLine_Tapped does not get called -->
            <TextBlock Text="{Binding name}" Tap="Debug_WriteLine_Tapped" />
        </DataTemplate>
    </toolkit:LongListMultiSelector.ItemTemplate>
</toolkit:LongListMultiSelector>

      

Basically what I am looking for is similar to the behavior of a standard mail app that, after selecting a bunch of letters, still receives events Tap

, because I can still expand / collapse any of them (except that in my case it is simple TextBlock

, and not ExpanderView

s).

+3


source to share


2 answers


Works fine on my machine. When I click these 3 items, I get the expected messages in the debug log.

<phone:LongListSelector ItemsSource="{Binding}">
    <phone:LongListSelector.ItemTemplate>
        <DataTemplate>
            <Grid >
                <TextBlock Text="{Binding}" Tap="TextBlock_Tap_1" />
            </Grid>
        </DataTemplate>
    </phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>

      



private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
    this.DataContext = "Foo Bar Baz".Split(' ');
}

private void TextBlock_Tap_1(object sender, GestureEventArgs e)
{
    Debug.WriteLine("TextBlock_Tap_1");
}

      

Depending on your scenario, WP8 provides a UseOptimizedManipulationRouting property that you might find useful. Setting UseOptimizedManipulationRouting = false causes LongListSelector, Pivot, and other controls not to swallow events for nested controls. A good place to set this to the root control of your LongListSelector.ItemTemplate.

0


source


The toolkit uses this sig to respond to a click.

private void OnItemContentTap(object sender, System.Windows.Input.GestureEventArgs e)

      

The sample defines a data template separate from the LongListMultiSelector construct in

<phone:PhoneApplicationPage.Resources>

      



and refers to it as

ItemTemplate="{StaticResource EmailItemTemplate}.

      

See LongListMultiSelectorSample.xaml in the toolbox for an example. The sample is actually incomplete and can be confusing at first. Just ignore BuddiesPivotItem and GridModeItem unless you want to finish it and make it all work.

0


source







All Articles