我在我的應用程序列表框。 以下是截圖。如何獲取列表項索引當用戶點擊在Windows Phone 8中的列表項中的按鈕
當列表項用戶點擊,那麼我顯示詳細的頁面。 它正在處理下面選擇更改的偵聽器。
private void companiesList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
//get the selected item from list
Company selectedItem = (Company)e.AddedItems[0];
Uri uri = new Uri("/CompanyDetailsPage.xaml", UriKind.Relative);
//navigate to target page
this.NavigationService.Navigate(uri);
FrameworkElement root = Application.Current.RootVisual as FrameworkElement;
root.DataContext = selectedItem;
}
}
高興這是好的。
現在,當用戶點擊該項目上的刪除按鈕, 然後我必須從列表中刪除該項目。
private void Del_Btn_clicked(object sender, RoutedEventArgs e)
{
//get the Corresponding item from list i.e. On which delete button is placed.
//Delete saved company from the database
}
我無法得到它的刪除按鈕被置於特定的列表項指標。 何我能得到。
謝謝。
我建議你將selectedItem到一個全局變量指數... ..然後用它來引用刪除按鈕 –