Reputation: 418
In my windows phone application I've a data bound list box. My data template contains many text blocks.
If I tap and hold on any of the text blocks, context menu appears. But if I tap and hold in the empty area of the listbox item the menu won't appear.
For example. If I select on any of the text area in the below mentioned image the menu appears. If I keep holding in the area between the name and date the menu is not appearing.
i want the menu to appear if I hold any where inside the particular list box item.
Note : I included the context menu
My xaml code goes as follows :
<ListBox.ItemTemplate>
<DataTemplate>
<Border BorderThickness="0.25,0.25,0.25,0.25" BorderBrush="{StaticResource PhoneForegroundBrush}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<toolkit:ContextMenuService.ContextMenu>
<toolkit:ContextMenu >
<toolkit:MenuItem
Header="delete"
Click="Delete" />
</toolkit:ContextMenu>
</toolkit:ContextMenuService.ContextMenu>
<TextBlock
HorizontalAlignment="Left"
TextWrapping="NoWrap"
Grid.Row="0"
Grid.ColumnSpan="2"
Text="{Binding TEXT}"
VerticalAlignment="Top"
FontWeight="Bold"/>
<TextBlock
HorizontalAlignment="Left"
TextWrapping="NoWrap"
Grid.Row="1"
Grid.Column="0"
Text="{Binding USERNAME}"
VerticalAlignment="Top"
FontSize="{StaticResource PhoneFontSizeSmall}"/>
<TextBlock
HorizontalAlignment="Right"
TextWrapping="NoWrap"
Grid.Row="1"
Grid.Column="1"
Text="{Binding Path=DATE}"
VerticalAlignment="Top"
FontSize="{StaticResource PhoneFontSizeSmall}" />
</Grid>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
is there any way to solve this ?
Thank you.
Upvotes: 0
Views: 734
Reputation: 4024
Add Background="{StaticResource TransparentBrush}"
to the Grid in the DataTemplate.
Upvotes: 6