我在处理事件时遇到问题。基本上该程序生成图像但具有相同的事件。
private Image MakeImage(string filename)
{
Uri uri = new Uri("ms-appx:///CategoryData/" + filename+".png");
BitmapImage bitmap = new BitmapImage(uri);
Image image = new Image()
{
Height = 100,
Width = 100,
Stretch = Stretch.Uniform,
MaxHeight = 250,
MaxWidth = 250,
HorizontalAlignment = HorizontalAlignment.Left,
VerticalAlignment = VerticalAlignment.Top,
Name = filename+"Img",
ManipulationMode = ManipulationModes.TranslateX | ManipulationModes.TranslateY,
};
image.Source = bitmap;
image.ManipulationDelta += image_ManipulationDelta;
return image;
}
void image_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
{
Image image = sender as Image;
CompositeTransform ct = image.RenderTransform as CompositeTransform;
ct.TranslateX += e.Delta.Translation.X;
ct.TranslateY += e.Delta.Translation.Y;
//throw new NotImplementedException();
}
并且在“”上发生异常ct.TranslateX += e.Delta.Translation.X;
。你调用的对象是空的。