如何管理事件LongListSelector_SelectionChanged先运行,然后运行Image_MouseLeftButtonDown
int count = 0;
Image LastImage = null, curImage = null;
BitmapImage bi1 = new BitmapImage();
BitmapImage bi2 = new BitmapImage();
int itemIndex;
void getImageLink()
{
for (int i = 0; i < CImageControl.lstImage.Count; i++)
s.Add(CImageControl.lstImage[i].ImageLink);
}
private void lstView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var myItem = ((LongListSelector)sender).SelectedItem as CImage;
itemIndex = ((LongListSelector)sender).ItemsSource.IndexOf(myItem);
//MessageBox.Show(myIndex.ToString());
}
然后这将运行
private void Image_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
string lastImageSource, lastImageAltSource, curImageSource, curImageAltSource;
count++;
if (count % 2 != 0)
{
LastImage = (Image)sender;
lastImageSource = s[itemIndex];
lastImageAltSource = lastImage.Source.ToString();
}
else
{
curImage = (Image)sender;
curImageSource = s[itemIndex];
curImageAltSource = curImage.Source.ToString();
}
}
ImageAltSouce
是图片的显示,我想用ImageSource
替换。但是在我可以更改任何源之前,我需要itemIndex
在Longlistselector中查找图像索引。由于事件Image_MouseLeftButtonDown首先出现,所以我不能做任何事情