- <ListBox Margin="0,0,-12,0" ItemsSource="{Binding Items}" >
- <ListBox.ItemTemplate>
- <DataTemplate>
- <StackPanel Orientation="Horizontal" Margin="0,0,0,17"
- MouseLeftButtonDown="StackPanel_MouseLeftButtonDown">
- <Image Height="150" Width="150" Source="{Binding ImageSource}" Stretch="UniformToFill" />
- <StackPanel Width="311">
- <TextBlock Text="{Binding LineOne}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
- <TextBlock Text="{Binding LineTwo}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
- </StackPanel>
- </StackPanel>
- </DataTemplate>
- </ListBox.ItemTemplate>
- </ListBox>
But on touch based platform such as Windows Phone 7, MouseLeftButtonDown will trigger event, even if You try scroll ListBox content. Another aproach is to use ManipulationCompleted event. Event arguments have property named IsTapEvent, but in latest Silverlight SDK this property is declared as Protected. So You can see it in debugger at runtime, but cannot use in code.
What You can do is subscribe to ManipulationCompleted event, and check e.TotalManipulation for Scale and Transform properties equals zero.
- private void StackPanel_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
- {
- var zero = new Point(0,0);
- if( e.TotalManipulation.Scale == zero && e.TotalManipulation.Translation == zero )
- MessageBox.Show("gotcha!");
- }
Mouse left button down ,mouse motion listner,onclick using silverlight is awesome coding.blog hosting review
ReplyDeleteIn this case it not big difference from using OnSelectionChange, but rely on selection also have issue - item remains in selected state and second tap on item doesn't fire event.
ReplyDeleteAnyway, thanks for opinion