.net - Adding my own WPF TriggerAction -


I am trying to add a custom trigger action to our code. The following XAML snippet is:

  style x: key = "ToolBarButtonStyle" TargetType = "button" & gt; & Lt; Style.Triggers & gt; & Lt; Event Trigger Routing Avent = "PreviewMouseDown" & gt; & Lt; Action: MyAction / & gt; & Lt; / EventTrigger & gt; & Lt; /Style.Triggers> ...   

MyAction is defined as follows:

  Public class MyAction: trigger action & lt; DependencyObject & gt; Call {safe override zero} (object parameter) {// something}}   

However, when I run the code, I get the following exception:

1) The given object should be an example of trigger action or derivative type.

The result: 'Add an exception' add value to the collection of 'System Windy Trigger Action Coalition'. Line number '29' and line position '15'.

I am running Visual Studio 2010, targeting .Net 4.0. any suggestion?

Adding any triggering action under the style of 'Event Trigger' expects action.

  System.Windows.TriggerAction   

Your custom action uses 'My work'

  System.Windows.Interactivity TriggerAction & LT; T & gt; (Normal type)   

And so you can try the following error. It seems that this is working in your case.

  & lt; Button content = "custom action" width = "150" height = "50" & gt; & Lt; Conversation: Interaction.Triggers & gt; & Lt; Conversation: EventTrigger EventName = "PreviewMouseDown" & gt; & Lt; Action: MyAction & gt; & Lt; / Action: MyAction & gt; & Lt; / Engagement: EventTrigger & gt; & Lt; / Engagement: Interaction.Triggers & gt; & Lt; / Button & gt;   

Here the alias has been added for interactivity. Let me know if you need more information

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -