刪除項目我有這個列表框在我的網頁:WP7從列表框中
<ListBox x:Name="lstData" Tap="lstData_Tap" ItemsSource="{Binding
Source={StaticResource favoriteAddressCollection},
Path=DataCollection}" Margin="22">
<ListBox.ItemTemplate >
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="/Images/Search/favorite_red.png" Margin="12" />
<TextBlock Text="{Binding Path=Address}" VerticalAlignment="Center" Width="300" />
<Button BorderThickness="0" Width="60" Height="60" HorizontalAlignment="Right"
Tap="imgDelete_Tap">
<Button.Background>
<ImageBrush ImageSource="/Images/Search/unfavorite.png"></ImageBrush>
</Button.Background>
</Button>
<!--<Image x:Name="imgDelete" Source="/Images/Search/unfavorite.png" Width="40" Margin="12" HorizontalAlignment="Right"
Tap="imgDelete_Tap" />-->
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
現在我想點擊該圖像後刪除項目。我沒有設置SelectedItem或SelectedIndex,所以我怎樣才能以其他方式刪除項目?如何找出我點擊圖像的哪一行?
這正是我所期待的。謝謝 – 2013-02-18 12:35:51