I am using Framework ElementFactory to create an image in a DataTemplate. When trying to process the MouseDown event for the image type, an exception was thrown - "The type of handler is invalid.
How can we add a MouseDownEventHandler for a FrameworkElementFactory of type Image
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));
The last line throws an exception. Please, help
source share