我有ListView
个图像和复选框,交替元素(图像,复选框,图像等)。
当我使用Thumbnails.SelectedIndex
时,它返回元素位置,但我只想要图像的元素位置并忽略复选框。
怎么做?
private void Thumbnails_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
int item = Thumbnails.SelectedIndex + 1; //get original index for each element in ListView
MessageBox.Show(Convert.ToString(item));
}
答案 0 :(得分:0)
private void Thumbnails_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
int item = Thumbnails.SelectedIndex + 1; //get original index for each element in ListView
object content = Thumbnails.SelectedItem;
if (content is Image)
{
MessageBox.Show(Convert.ToString(item));
}
}