Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何将事件处理程序设置为控件?_C#_Wpf_Silverlight_Xaml_Windows 8 - Fatal编程技术网

C# 如何将事件处理程序设置为控件?

C# 如何将事件处理程序设置为控件?,c#,wpf,silverlight,xaml,windows-8,C#,Wpf,Silverlight,Xaml,Windows 8,我不熟悉使用xaml和c#开发windows 8应用程序。我创建了一个新的图像使用 Image img = new Image(); 我成功地将图像添加到画布,但我想添加一个已压缩到img的eventhandler指针。我该怎么做呢?您的图像实例都在代码中 Image img = new Image(); 我假设您已经在代码中将它添加到画布中,因此在代码中钩住事件是合乎逻辑的 Image img = new Image(); img.PointerPressed += Image_Poi

我不熟悉使用xaml和c#开发windows 8应用程序。我创建了一个新的图像使用

  Image img = new Image();

我成功地将图像添加到画布,但我想添加一个已压缩到img的eventhandler指针。我该怎么做呢?

您的图像实例都在代码中

Image img = new Image();
我假设您已经在代码中将它添加到画布中,因此在代码中钩住事件是合乎逻辑的

Image img = new Image();
img.PointerPressed += Image_PointerPressed;
您已经在同一类的其他地方定义了压缩的图像\u指针

private void Image_PointerPressed(object sender, PointerRoutedEventArgs e)
{
    // do what you want here...
}

应该是另一个帖子,但我想你想要的是img.manufactionmode=manufactionmodes.All;