我在此项目控件中放置了一个点击事件,以便在点击图像时查看图像,但是当我这样做时,我收到此错误,我该如何修复它。我尝试更改为项目图像但不存在。
XAML 代码:
<ItemsControl x:Name="icPareoExerciseControl1"
HorizontalAlignment="Left"
VerticalAlignment="Top"
ItemsSource="{Binding lstPareoItem}"
ItemTemplate="{StaticResource ExercisePareoDataTemplate2}"
Foreground="Black" Width="400"
Margin="100,0,0,0"
Tapped="inlineImage_Tapped"/>
Code:
private void inlineImage_Tapped(object sender, TappedRoutedEventArgs e)
{
Image temp = (Image)sender;
if (temp.DataContext is MultimediaElement)
{
}
else
{
Image ImageToGrid = (Image)sender;
ImageContent myImage = new ImageContent();
myImage.ImgUri = ImageToGrid.Source.ToString();
ImageSource imgSource = ImageToGrid.Source;
gridGallery.Visibility = Visibility.Visible;
stckImageMenuGallery.Visibility = Visibility.Collapsed;
ImageGalleryUri = (imgSource as BitmapImage).UriSource.OriginalString;
imgPopup.Source = ImageToGrid.Source;
}
}
The Tapped
路由事件绑定到ItemsControl
,不至于Image
.
这会导致这一行失败:
Image temp = (Image)sender;
在这种情况下应该是:
ItemsControl temp = (ItemsControl)sender;
更改您的代码,使其绑定到Image
你正在你的ItemsControl
。然后第一个演员就可以工作了。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)