我正在使用框架ElementFactory在DataTemplate中创建图像。当尝试处理图像类型的MouseDown事件时,抛出异常-“处理程序类型无效。
如何为类型为FrameworkElementFactory的图像添加MouseDownEventHandler
FrameworkElementFactory imageSecondaryContent = new FrameworkElementFactory(typeof(Image));
imageSecondaryContent.SetValue(Image.WidthProperty, imgWidth);
imageSecondaryContent.SetValue(Image.VisibilityProperty, Visibility.Hidden);
imageSecondaryContent.Name = imageName;
Binding tmpBindingSecondaryContent = new Binding();
tmpBindingSecondaryContent.Source = IconLibary.GetUri(IconStore.ExclaminationPoint);
imageSecondaryContent.SetBinding(Image.SourceProperty, tmpBindingSecondaryContent);
imageSecondaryContent.AddHandler(Image.MouseDownEvent, new RoutedEventHandler(Test));最后一行抛出一个异常。请帮帮忙
发布于 2011-09-07 16:09:25
我知道答案了。它是
imageSecondaryContent.AddHandler(Image.MouseDownEvent, new MouseButtonEventHandler(Test));如果您认为需要关闭该问题,请关闭该问题。
https://stackoverflow.com/questions/7330428
复制相似问题