locked
How to disable tapped event in a listview with list of textblocks ?

    Question

  • i want when a user tap on anything inside a listview all controls should not respond to the tapped event ,how can i achieve this . this is my listview 
    <ListView x:Name="listviewAgenda" IsTabStop="True" ItemsSource="{Binding}" CanDragItems="False" IsActiveView="False" IsTapEnabled="False"  IsSwipeEnabled="False" SelectionMode="None" Margin="10,27,-1,9" >
                                        <ListView.ItemTemplate>
                                            <DataTemplate>
                                                <StackPanel Orientation="Vertical" Margin="5" Width="Auto">
                                                    <TextBlock Text="{Binding AgendaData_Title}" Margin="8,0,0,0" FontSize="28" Foreground="#10879a" TextWrapping="Wrap" FontWeight="Normal"></TextBlock>
                                                    <ListView x:Name="listviewPacks" ItemsSource="{Binding MeetingPacks}" SelectionMode="None" Margin="5" Width="800">
                                                        <ListView.ItemTemplate>
                                                            <DataTemplate>
                                                                <ItemsControl>
                                                                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                                                                        <StackPanel Orientation="Vertical" Grid.Column="0" Width="350">
                                                                            <TextBlock Text="{Binding MeetingPackData_FileName}" FontSize="18" Tag="{Binding MeetingPackData_FileName}" Foreground="Gray" TextWrapping="Wrap" />
                                                                        </StackPanel>
                                                                        <StackPanel Width="200">
                                                                        </StackPanel>
                                                                        <Border BorderThickness="1" BorderBrush="#10879a" Margin="0,0,0,0" CornerRadius="4,4,4,4">
                                                                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Width="120" Margin="50,10,0,0">
                                                                                <TextBlock Text="View Doc" Tag="{Binding MeetingPackData_FileName}" Foreground="#10879a" FontSize="15" HorizontalAlignment="Center" Tapped="viewDoc_Tapped"/>
                                                                                <Image Source="{Binding MeetingPackData_FileType, Mode=OneWay, Converter={StaticResource FileExtToImage}}" Height="30" Width="50" HorizontalAlignment="Right"/>
                                                                            </StackPanel>
                                                                        </Border>
                                                                    </StackPanel>
                                                                </ItemsControl>
                                                            </DataTemplate>
                                                        </ListView.ItemTemplate>
                                                    </ListView>
                                                    <StackPanel Height="20">
                                                    </StackPanel>
                                                    <Line X1="0" Y1="0" X2="10000" Y2="0" Stroke="Gray" />
    
                                                </StackPanel>
                                            </DataTemplate>
                                        </ListView.ItemTemplate>
    
                                    </ListView>


    19karabo91

    Wednesday, April 23, 2014 1:23 PM

Answers

  • Try this:

    ListView.IsEnabled = false;
    


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    • Proposed as answer by Shreeharsh Ambli Thursday, April 24, 2014 6:12 AM
    • Marked as answer by 19karabo91 Thursday, April 24, 2014 6:14 AM
    Wednesday, April 23, 2014 7:59 PM
    Moderator

All replies

  • Try this:

    ListView.IsEnabled = false;
    


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    • Proposed as answer by Shreeharsh Ambli Thursday, April 24, 2014 6:12 AM
    • Marked as answer by 19karabo91 Thursday, April 24, 2014 6:14 AM
    Wednesday, April 23, 2014 7:59 PM
    Moderator
  • it works great but it reduce the colour of the list view and i am unable to click my buttons inside the listview.

    19karabo91

    Thursday, April 24, 2014 5:42 AM
  • You should be able to change the style of the disabled control.  And of course, you aren't able to click the buttons - that's what you asked for.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, April 24, 2014 11:49 AM
    Moderator